Moving Files

Rather than copying files, it is often desirable to move them instead, especially if disk space is at a premium on your network. Robocopy's /MOVE switch provides this facility. It causes source files to be deleted from the source directory tree after they have been successfully copied to the destination.

Note that even with /MOVE specified, Robocopy will only delete those source files that it successfully copies to the destination. This applies even to skipped Same files as there is no absolute guarantee that a skipped source file is identical to its corresponding destination file, even if the file times and sizes are identical, until immediately following a successful copy.

Therefore it is perfectly normal for files and directories to remain in the source tree even after a Robocopy has walked the tree with /MOVE specified. The user must decide whether or not it is safe to delete the remaining entries, and, if so, delete them manually.

True Replication

If you require the destination directory tree to be maintained as an exact mirror of the source directory tree, and have files and directories deleted from the destination whenever they disappear from the source, you can use the /PURGE switch (at your own risk).

/PURGE causes Robocopy to delete ALL Extra and Mismatched destination files and directories. After a Mismatched destination entry has been deleted, the corresponding source entry is then treated as a Lonely file or directory, and processed accordingly.

Where /PURGE results in the deletion of an Extra or Mismatched destination directory, the entire directory tree, including all subordinate files and subdirectories, will be deleted.

You should use /PURGE with extreme caution. If you specify /PURGE along with an incorrect (but existing) destination directory, Robocopy WILL DELETE lots of data from the destination very quickly. You use the /PURGE option at your own risk.

Note that the /XX switch excludes Extra files from further processing, so /PURGE will have no effect if /XX is also used.