Thursday, June 16, 2011

Robocopy error log

C:\>type robocopy.log | find "(0x" > robocopyerrors.log

If you've used robocopy to back up files and log the process, you probably have a massive, unwieldy robocopy log which lists every single file that was copied. That's all fine, but what if it tells you there were 100 files that failed to copy? How do you know which ones?

Now, I'll admit, if you only have a small handful of failed files, it's probably easier to open the log in notepad and find them with CTRL-F. You can search for "error," but that may not be ideal if you have a lot of files with "error" in the path. A better search term is "(0x", which is the beginning of the error code number.

Once the number of errors hits double-digits, it's probably better to be able to see the errors by themselves without dealing with having to click Find Next. The above command will list the entire file, find only the lines containing error codes, and save the results as robocopyerrors.log. The only real downside is that you don't get the human-readable error, just the code. The error message is saved one line below the error code, so retrieving it would involve some complex command line jujitsu. I may tackle that some other day.

2 comments: