I am using the following batch file to run my robocopy command:
@ECHO OFF
for /f %%a in ('wmic os get LocalDateTime ^| findstr ^[0-9]') do (set ts=%%a)
robocopy [source] [target] /log+:D:\logs\log_%ts:~0,8%.log /e /xo /w:10 /r:1000 /z /NP
robocopy [source] [target] /log+:D:\logs\log_%ts:~0,8%.log /e /xo /w:10 /r:1000 /z /NP
This helped me log all the details I was looking for except that it did not logged the names of the skipped/failed files. Is there a script/robocopy command/any other way to log the names of the skipped/failed files to help me determine such files. It becomes really difficult to determine such files for a large volume of file transfer over the network.
The closest I came to a similar question is this, but even that didn't had any accepted/working answers
EDIT 1: As per the comment by Kamen Minkov, I included /v (verbose) in my robocopy command). When I purposefully failed the file transfer, it logged the error (retries history), but this makes the log file more and more harder to interpret. The same case was observed even without /v. I just want the failed transfer file name to be logged as failed once in my .txt log file
EDIT 2: As per JosefZ's Answer, I ran the following code:
@ECHO OFF
for /f %%a in ('wmic os get LocalDateTime ^| findstr ^[0-9]') do (set ts=%%a)
robocopy [source] [target] /log+:D:\logs\log_%ts:~0,8%.log /e /xo /w:10 /r:0 /z /NP /V
if errorlevel 8 findstr "^[0-9,a-Z]" "D:\logs\log_%ts:~0,8%.log"
This gave me following error after transferring all the files (I unplugged the network cable to fail a few files, so there were failed files):
FINDSTR: Cannot open D:\ABC\log\ErrorLog_20151029_1035.log
EDIT 3: The above error occurred because I incorrectly mentioned the name of the log file for exit code. The correct code is (As answered by JosefZ):
@ECHO OFF
for /f %%a in ('wmic os get LocalDateTime ^| findstr ^[0-9]') do (set ts=%%a)
robocopy [source] [target] /log+:D:\ABC\log\log_%ts:~0,8%_%ts:~8,4%.log /e /xo /w:10 /r:2 /z /NP /V /TEE
if errorlevel 8 findstr "^[0-9,a-Z]" "D:\ABC\log\log_%ts:~0,8%_%ts:~8,4%.log"
/XO
is an exclusion of older files, so while they may seem to be "skipped", they won't be logged because they are not actually skipped, but instead excluded (completely) from processing - no processing = noting to log./r:1000
gives me no sense in log file. Use/r:0
to make easy subsequent investigation of incidental errors and their cause.