Re: DOS Batch: MOVE command return 0 when file not moved
- From: mr_unreliable <kindlyReplyToNewsgroup@xxxxxxxxxxx>
- Date: Tue, 13 Mar 2007 14:52:03 -0400
hi LiuYan,
If you are willing to break out of bat file code and use
script, then you could use the "free space" method to
determine if there was enough space on the target disk
ahead of time.
If you must stick with bat commands, I seem to recall
that there is an "if exist filespec" command. I suggest
that you use the "if exist" to see if your new file was
successfully copied, before deleting the old file.
cheers, jw
____________________________________________________________
You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)
LiuYan 刘研 wrote:
I have a DOS batch script file which move/collect file from 5 machines to 1 machine..
I use 'move' command to do this, but when the destination disk is full, the %ERRORLEVEL% will be 0 which I thought the files are moved successfully, then I delete the source files, and so, I've lost these files.....
Why 'move' return '0' while file are not moved ??? Does '0' means success??? How can I make sure the file are moved successfully or not ??? Thanks !!!
Here is a piece of source code:
--------------------------
echo Moving files... >> "%LOG_FILE%"
move "%SOURCE_DIRECTORY%\*.*" "%DESTINATION_DIRECTORY%" 1>>"%LOG_FILE%" 2>>&1
echo MoveFilesResult ERRORLEVEL=%ERRORLEVEL% >> "%LOG_FILE%"
if "%ERRORLEVEL%"=="0" (
echo Removing direcotry... >> "%LOG_FILE%"
rmdir "%SOURCE_DIRECTORY%" 1>>"%LOG_FILE%" 2>>&1
echo RemoveDirectoryResult ERRORLEVEL=%ERRORLEVEL% >> "%LOG_FILE%"
) else (
echo Move files error >> "%LOG_FILE%"
)
- Prev by Date: Re: Converting a date From US format (MM-DD-YY) to UK format (DD-MM-YY) or Vice-versa
- Next by Date: Re: OLE error
- Previous by thread: Re: Strange Error...
- Next by thread: Accessing features of Python, Perl, Tcl, Ruby and Rex from VBScript
- Index(es):
Relevant Pages
|