Solved

Pipe output to a file with a batch file

Posted on 2007-12-04
4
6,347 Views
Last Modified: 2010-01-12
I am setting up a batch job that will transfer files to several machines.  How do i send the output to a file so i can tell if any machines got missed?

i would echo the machine name, then i need to send the output of if it copied or not after it.
0
Comment
Question by:Fraser_Admin
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
weareit earned 250 total points
ID: 20404199
you can use the > charactor to redirect the output to a file.

> will overwrite
>> will append

i.e.

echo Todays date is > date.txt
date >> date.txt

-saige-
0
 
LVL 4

Assisted Solution

by:gabbadar
gabbadar earned 250 total points
ID: 20404276
You can send the output of any command to file using the > or >> characters:
> - will create a new file
>> - will append to an existing file (or create if non existent)

So this would be a good start:




Echo Server1 >> c:\CopyLog.txt
xcopy \\server1\share\* \\my\destination >>c:\CopyLog.txt
Echo ---------- >> c:\CopyLog.txt
Echo Server2 >> c:\CopyLog.txt
xcopy \\server2\share\* \\my\destination >>c:\CopyLog.txt

Open in new window

0
 

Author Comment

by:Fraser_Admin
ID: 20404783
how do i send the date.  when i do date > output.txt it waits for me to press enter.  i also want to have the date/time combination?
0
 
LVL 4

Expert Comment

by:gabbadar
ID: 20405520
Rather than use the date/time program, use the variables:

echo %date% - %time%
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now