I am trying to use robocopy to move files from a source directory to a destination directory. The problem is that an inetpub mail process monitors the destination directory, and quickly locks and deletes files placed there. Here's what seems to be happening:

1) I call

Robocopy C:\test c:\test1 /COPY:D /MOV /IPG:50 /R:1000000 /W:30 /Z /Log:C:\robolog\RoboLog.txt

Robocopy seems to ignore the /D switch, and includes this in the log:

   Source : C:\test\
     Dest : c:\test1\

    Files : *.*

  Options : *.* /COPY:DT /MOV /Z /IPG:50 /R:1000000 /W:30 

2) I suspect that Robocopy copies the data to the destination, then writes the timestamp, then deletes the file from the source directory. Because inetpub deletes some files before Robocopy can write the timestamp, I see errors in the log like this:

2011/08/18 10:17:06 ERROR 2 (0x00000002) Time-Stamping Destination File C:\test\Foo.txt

The affected files are copied, but they also remain in the source directory

3) Robocopy fails with error 9 because of the files that were copied but not deleted.

Is there a way to fix this? If my assessment is correct, then if I could get Robocopy to copy just the data and leave timestamps as a default value, that would work.

  • I wasn't able to get Robocopy to move files atomically, I wrote my own program that turns off the external process that locks the files while files are being moved. Aug 29, 2011 at 20:51

1 Answer 1


I've got a feeling the files are locked when you try to delete them.
Look at using Volume Shadow copy, that should ensure that you get the files you need with out them getting deleted.
Although that complicates delteting the files automatically. You'd need to write a script(another part of your current script ) to go through and clean up the files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.