Saving a batch file output

Associate
Joined
16 Mar 2004
Posts
1,920
Location
Oxford
I have recently produced a batch file to copy the contents of one disk to another over the network; however is it possible to add to this batch file so that it saves a text file of all the actions that have taken place to a location over the network?
 
You can do something like:

myscript.bat >> c:\output.txt

Which will save the output of the batch file to a text file. Or you can do:

myscript.bat > C:\output.txt

Which appends the output to the end of the file.

You can also call it on other commands within a batch file such as:

dir /w >> output.bat
 
Thanks for your help, I have just managed to get it to save to a text file using a slightly different method.

Code:
>\\hdd1\backup-txt\batchfileoutput.txt

Pretty simple really! However is it possible to add the time and date to the text file so that I can view the text file and see when it was created.

For example at the end of the file it says:

Code:
11612 File(s) copied

Time/Date Goes Here
 
Hi,

In DOS you can output the current date and time from a batch file by using something like:

echo %date% / %time%

Redirecting the output from the DOS to the file would then put the date/time info onto the file.

I'm certainly no DOS expert so there are probably lots of better ways of doing that and to change the formatting etc. Hope it helps anyway.

Jim
 
Back
Top Bottom