You are not logged in.
Pages: 1
Hi,
I have this problem, when running robocopy script and there is not enough disk space on the destination hard-drive, robocopy gives the error 112 "There is not enough space on the disk." How could I make it so, that if error 112 comes for the first time, robocopy will stop the copy process and does not try to copy the rest of the files?
Offline
Not in a straight forward way.
In general, the only way to be able to guarantee that robocopy will stop on the first error it encounters would be to run it once per file using a "for" loop in some fashion and check the errorlevel code it generates.
To make sure it only stops on a particular error such as the out of space one would just need a bit of checking of robocopy's output.
Something along these lines should do the trick (not thoroughly tested):
@echo off
set "source=X:\Your Source Directory"
set "target=Y:\Your Target Directory"
set "files=*.*"
set "log=%~dpn0.log"
call :copy.files
if errorlevel 1 echo:Out of space: "%target%" & echo:Run aborted.
pause
goto :EOF
:copy.files
for /f "usebackq tokens=*" %%a in (`dir /b/a:-d/o:n "%source%\%files%"`) do (
robocopy "%source%" "%target%" "%%~nxa" /log:"%log%" /r:0 /njs /njh /tee /np
if errorlevel 1 (
type "%log%" | findstr /b "..../../.. ..:..:.. ERROR 112 " >nul
if not errorlevel 1 exit /b 1
)
)
exit /b 0
Last edited by bluesxman (14 Apr 2009 21:34)
cmd | *sh | ruby | chef
Offline
Thank you for this!
Offline
Pages: 1