Feature Post

Top

DOS Move command doesn't work on Windows 2003 Server?

MOVE command doesnt work in Windows 2003 Server; workaround?

To emulate the process, we can create a batch file and:
  • Copy the file to new folder
  • Verify the copied file
  • Delete the file from old folder

@echo off

echo -----------------------------------------
ECHO File Move Utility for Windows 2003 Server
echo -----------------------------------------

set /p loc1= Copy From location 1: 
set /p loc2= Copy To location 2: 

@echo Copying...
copy /b "%loc1%" "%loc2%"

@echo Validating...
fc /b "%loc2%"  "%loc1%" |find /i "Ditto" > nul

@echo Cleaning...
if not errorlevel 1 del /f "%loc1%"

@echo Logging...
if not errorlevel 1 >>"file.log" echo File copied successfully
if errorlevel 1 >>"file.log" echo Error removing file from "%loc1%"

@echo Complete.

A couple of gotchas to keep an eye on:
  • You could have used the MOVE.EXE command if its available on your OS; move simply alters the folder information, which means it does not move the data. While COPY.EXE may do.
  • When you compare the file, it most probably compares the contents with disk cache. In order to test, you can copy the file on a flash drive, a pause for a while, pull out the flash drive, and then compare. If it does not look for the flash drive, this means the OS uses the cached version instead.
  • Copy does not copy files that are 0 bytes long. Use XCOPY.exe to copy these files.