Re: DOS Batch: MOVE command return 0 when file not moved

Tech-Archive recommends: Speed Up your PC by fixing your registry



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%"
)




.



Relevant Pages

  • Weird disk problem
    ... Using QTParted I discovered the second disk has a lot of free space. ... I can not use it to allocate a new partition, ... But fdisk doesn't recofnize the space at all. ... Command: p ...
    (Fedora)
  • Re: Move Home to 2nd drive
    ... Prior to the upgrade the 1st ... drive had 2.2Gb free space on it. ... Any quick/easy command line suggestions on how to do this? ... sudo mv /home /home.bak ...
    (Ubuntu)
  • Re: SDI Manager
    ... Packs the file by removing free space and moves the binary large object ... of type BOOT to first BLOB position. ... pack is used with some type of boot scenarios for BLOB sort and alignment ... > This command removes all unused space from the file. ...
    (microsoft.public.windowsxp.embedded)
  • Re: Hard Drive showing 0 bytes available
    ... Boot into normal mode. ... I also recommend that you run this command: ... In Safe mode, it shows 0 bytes for both total space and free space, you ...
    (microsoft.public.windowsxp.general)
  • Re: How to determine oracle user size?
    ... I note that simply cutting and pasting the command gives no results, ... That users tablespace is 46,200MB. ... evaluate free space in tablespaces, and users may not control how much ...
    (comp.databases.oracle.server)