Created
February 4, 2021 13:43
-
-
Save f-steff/784e1d520a99e1ffb101704ce1cd1943 to your computer and use it in GitHub Desktop.
Use Robocopy in Batch scripts and understand the errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| echo FETCHING files... | |
| set "source=\\myFileServer\FileServer\Files_To_Go_Onto_CD" | |
| set "dest=.\CD_FILES" | |
| robocopy %source% %dest% | |
| if %ERRORLEVEL% EQU 16 echo ***FATAL ERROR*** & goto fail | |
| if %ERRORLEVEL% EQU 15 echo OKCOPY + FAIL + MISMATCHES + XTRA & goto fail | |
| if %ERRORLEVEL% EQU 14 echo FAIL + MISMATCHES + XTRA & goto fail | |
| if %ERRORLEVEL% EQU 13 echo OKCOPY + FAIL + MISMATCHES & goto fail | |
| if %ERRORLEVEL% EQU 12 echo FAIL + MISMATCHES& goto fail | |
| if %ERRORLEVEL% EQU 11 echo OKCOPY + FAIL + XTRA & goto fail | |
| if %ERRORLEVEL% EQU 10 echo FAIL + XTRA & goto fail | |
| if %ERRORLEVEL% EQU 9 echo OKCOPY + FAIL & goto fail | |
| if %ERRORLEVEL% EQU 8 echo FAIL & goto fail | |
| if %ERRORLEVEL% EQU 7 echo OKCOPY + MISMATCHES + XTRA & goto end | |
| if %ERRORLEVEL% EQU 6 echo MISMATCHES + XTRA & goto end | |
| if %ERRORLEVEL% EQU 5 echo OKCOPY + MISMATCHES & goto end | |
| if %ERRORLEVEL% EQU 4 echo MISMATCHES & goto end | |
| if %ERRORLEVEL% EQU 3 echo OKCOPY + XTRA & goto end | |
| if %ERRORLEVEL% EQU 2 echo XTRA & goto end | |
| if %ERRORLEVEL% EQU 1 echo OKCOPY & goto end | |
| if %ERRORLEVEL% EQU 0 echo No Change & goto end | |
| :end | |
| exit /b 0 | |
| :fail | |
| exit /b %ERRORLEVEL% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment