Hi, I’m trying to create a batch file that will stop the xcopy and delete batch process and return a “Drive Full” statement, if there is not enough space on my destination drive. This is what I have so far:
set /p INPUT= Enter PREVIOUS Date (ddmmyyyy) for which you want to create an ARCHIVE folder:
xcopy “i:\*.*” “h:\archive\graphics\%INPUT%” /D /E /R /I /K /-Y || goto Error
echo y | rd /s /q i:\DailyWork
echo y | del i:\Clients.xls
echo The Archive Drive is FULL! STOPPING Backup Procedure.
The batch file does stop, when the backup drive is full, but instead of showing the error statement about the drive being full, I get a message that instead states …
“Insufficient disk space on current disk.
Insert another disk and type <Return> to continue…”
… and I have to hit the “X” control button in the upper right of the batch’s pop-up window to close out of and exit the batch file. I’ve also tried the following variations, but the batch file ended with the same result:
1) xcopy “i:\*.*” “h:\archive\graphics\%INPUT%” /D /E /R /I /K /-Y || goto :Error
(adding the colon before the word Error)
2) xcopy “i:\*.*” “h:\archive\graphics\%INPUT%” /D /E /R /I /K /-Y
if %ErrorLevel% GTR 0 goto Error
From what I understand, batch file exit codes go from 0 to 5, and the code pertaining to insufficient disk space is 4 … but to be save, I should have any code greater than 0 stop my xcopy/delete batch.
I would greatly appreciate any help in correcting my coding syntax for this batch file. Thanks so much!