Friday, July 24, 2009

Robocopy Exit Codes

Return codes list that are used by the Robocopy utility:

  • 0 No files were copied. No failure was encountered. No files were mismatched. The files already exist in the destination directory; therefore, the copy operation was skipped.
  • 1 All files were copied successfully.
  • 2 There are some additional files in the destination directory that are not present in the source directory. No files were copied.
  • 3 Some files were copied. Additional files were present. No failure was encountered.
  • 5 Some files were copied. Some files were mismatched. No failure was encountered.
  • 6 Additional files and mismatched files exist. No files were copied and no failures were encountered. This means that the files already exist in the destination directory.
  • 7 Files were copied, a file mismatch was present, and additional files were present.
  • 8 Several files did not copy.
  • Any value greater than 8 indicates that there was at least one failure during the copy operation.

Here are a full details of the return codes that could be in a batch file:
if errorlevel 16 echo ***FATAL ERROR*** & goto end
if errorlevel 15 echo FAIL MISM XTRA COPY & goto end
if errorlevel 14 echo FAIL MISM XTRA & goto end
if errorlevel 13 echo FAIL MISM COPY & goto end
if errorlevel 12 echo FAIL MISM & goto end
if errorlevel 11 echo FAIL XTRA COPY & goto end
if errorlevel 10 echo FAIL XTRA & goto end
if errorlevel 9 echo FAIL COPY & goto end
if errorlevel 8 echo FAIL & goto end
if errorlevel 7 echo MISM XTRA COPY & goto end
if errorlevel 6 echo MISM XTRA & goto end
if errorlevel 5 echo MISM COPY & goto end
if errorlevel 4 echo MISM & goto end
if errorlevel 3 echo XTRA COPY & goto end
if errorlevel 2 echo XTRA & goto end
if errorlevel 1 echo COPY & goto end
if errorlevel 0 echo –no change– & goto end
:end

For Robocopy Syntax see http://technet.microsoft.com/en-us/library/cc733145(WS.10).aspx