[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6400
  • Last Modified:

Pipe output to a file with a batch file

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
Fraser_Admin
Asked:
Fraser_Admin
  • 2
2 Solutions
 
weareitCommented:
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
 
gabbadarCommented:
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
 
Fraser_AdminAuthor Commented:
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
 
gabbadarCommented:
Rather than use the date/time program, use the variables:

echo %date% - %time%
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now