Robocopy Scripts with logging.

Always struggle to remember this so put it here:

Point is to create logfile with todays date in the name so we get a new file each day


echo on
for /F "tokens=1-6 delims=/ " %%A in ('date /t') do ( set dt=%%D_%%C_%%B_)
set logfile=C:\it\logfiles\%dt%_copy_logfile.txt

echo %logfile%
date /t >> %logfile%
time /t >> %logfile%
echo %0 >> %logfile%
echo "************ Copy these files ************* >> %logfile%
robocopy \\server\files\applications\ "D:\Applications\" /s /r:0 /tee /log+:%logfile% /np /ndl /xo /purge

About Jeff Turner

Technical director of Nano Tera Network Solutions.
This entry was posted in Hints and Tips, System Administration. Bookmark the permalink.