I just need some help with creating a log file for a batch script I'm running at the moment. As I move files from 1 server to another it would be handy to know when things have been moved over.
At the moment I've tried a few things like:
if %errorlevel% GTR 0 (echo MOVE FAILURE>Logs\log.txt) else (echo MOVE SUCCESSFUL>Logs\log.txt)
But this just gets to be sloppy code, as I would have to put it after every line, and it doesn't tell me the name of the file I have just moved.
Here is my code at the moment:
@Echo OFF
cd C:\Test
MOVE "Home\*.*" "Work"
Echo COMPLETE
Pause
Of course there's more lines, about another 20, but for the sake of testing I just have the one folder, and the folder names are just placebos.
Now I can use the default return screen by the Move Command
C:\Test\Home\Test.txt
1 file(s) moved.
But I don't know how to move that output into a simple .txt file that I can just keep a record off.
By the way if there a better way or better program to write it in let me know, and I'll investigate!
try this:
Courtesy of dbenham : You should investigate the ROBOCOPY command. It has options to move files, and it can give a complete log of what was done.
is what I've used! Works fine, not perfect but give me oversight into what has been moved!