Solved

Pipe output to a file with a batch file

Posted on 2007-12-04
4
6,340 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

21 Experts available now in Live!

Get 1:1 Help Now