davidpm
asked on
batch file logging
The following is a batch file that I am using for an auxilery backup
xcopy \\dc1\data\*.* d:\public\data /s /d /c /y /i
xcopy \\dc1\doc\*.* d:\public\doc /s /d /c /y /i
xcopy \\dc1\archive\*.* d:\public\archive /s /d /c /y /i
xcopy \\server2b\public2\*.* d:\public\public2 /s /d /c /y /i
What I would like to have happen is that in the d:\public directory
I get a file created every day that looks like this: 2003-04-05 Sat.txt
And in that file are lines something like
\\dc1\data OK
\\dc1\doc Failed
\\dc1\archive OK
\\server2b OK
I know I using the continue on error xcopy switch so the error code will probably return OK even if some files did not copy.
At least I would know that each line executed and that would be good enough.
Anyone have some batch file code that would do this?
xcopy \\dc1\data\*.* d:\public\data /s /d /c /y /i
xcopy \\dc1\doc\*.* d:\public\doc /s /d /c /y /i
xcopy \\dc1\archive\*.* d:\public\archive /s /d /c /y /i
xcopy \\server2b\public2\*.* d:\public\public2 /s /d /c /y /i
What I would like to have happen is that in the d:\public directory
I get a file created every day that looks like this: 2003-04-05 Sat.txt
And in that file are lines something like
\\dc1\data OK
\\dc1\doc Failed
\\dc1\archive OK
\\server2b OK
I know I using the continue on error xcopy switch so the error code will probably return OK even if some files did not copy.
At least I would know that each line executed and that would be good enough.
Anyone have some batch file code that would do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you would like to get a easy report in text form, try using the "RoboCopy.exe" from the Windows 2000 Resource Kit. Using this in a batch file along with piping the results to a text document should give you a nice report. It is a nice alternative to "Xcopy".
Hope this helps,
Mirfster.
Hope this helps,
Mirfster.
ASKER
My final solution used part from you and mirfster. Attached is what I plan on using. It seems to work great.
Where you came up with the syntax for the set filename I would be intersted in if you have a resource.
Mirfster I knew about robocopy and xxcopy but forgot about the reporting facility.
I have created an new question for you. Just log in to the question "batch file logging for mirfster" and collect your points.
set filename=%date:~10,4%-%dat e:~4,2%-%d ate:~7,2% %date:~0,3%.txt
robocopy \\dc1\doc\david d:\test\david /s /np /eta /log:"%filename%"
robocopy \\dc1\doc\bob d:\test\bob /s /np /eta /log+:"%filename%"
Where you came up with the syntax for the set filename I would be intersted in if you have a resource.
Mirfster I knew about robocopy and xxcopy but forgot about the reporting facility.
I have created an new question for you. Just log in to the question "batch file logging for mirfster" and collect your points.
set filename=%date:~10,4%-%dat
robocopy \\dc1\doc\david d:\test\david /s /np /eta /log:"%filename%"
robocopy \\dc1\doc\bob d:\test\bob /s /np /eta /log+:"%filename%"
davidpm:
set/? from the command prompt.
AAMOI, there's a potential problem with the date/t or %date% syntax on XP caused by some Microsoft brainstorming. Very messy - just in case you choose the "wrong" options should you upgrade.
<hobbyhorse>
For more discussion:
https://www.experts-exchange.com/questions/20571603/DATE-T-OS-When-is-XP-not-XP.html
or
https://www.experts-exchange.com/questions/20577896/Copy-files-2-day-before-current-date.html
</hobbyhorse>
set/? from the command prompt.
AAMOI, there's a potential problem with the date/t or %date% syntax on XP caused by some Microsoft brainstorming. Very messy - just in case you choose the "wrong" options should you upgrade.
<hobbyhorse>
For more discussion:
https://www.experts-exchange.com/questions/20571603/DATE-T-OS-When-is-XP-not-XP.html
or
https://www.experts-exchange.com/questions/20577896/Copy-files-2-day-before-current-date.html
</hobbyhorse>
Thanks for the points davidpm, I'll make sure to go to that question.
Best off luck.
Mirfster
Best off luck.
Mirfster
date < yes.txt >test.txt
What this does is output the contents of the date command to test.txt. Yes.txt needs to contain the commands necessary to get the date command to complete--a single enter key, usually. Piping in yes.txt to the date command automates the completion of the command. By placing the date command after the xcopy command, the only way it can be executed is if the xcopy command completes. Test.txt will then contain a date entry for each time your batch file runs.
Hope this helps.
Nick