We copied all our files to a new storage server recently. We didn't want to move at the time because we weren't sure if files would get lost.

The problem now is that we have files on both places.

How can we move only the files that do not exist in the target and for those that exist in both places we delete it from the source? It is Windows Server 2008.


Use a compare tool like Beyond Compare. It can compare folders and shows you what files exist and don't exit in the folders and subfolders. Also, it shows if there are any differences between files that exist on both locations. beyond compare can also copy and/or move files from one folder to another.

| improve this answer | |
  • I ended up using this as I could easily do this step by step! – Oskar Kjellin Mar 19 '10 at 10:14

This leaves newer files in NEWDIR alone. Files in NEWDIR that are the same or older will get overwritten.


This does something similar - watch out for extra file deletion on this one.

The semantics of the /XO command are backwards.

I just set up a set of source and destination directories and proved it to myself, as no documentation explains the true meaning of "Exclude Newer". Newer what? Newer source? Newer destination? What?


  1. Do the copy.

  2. Edit a file in NEWDIR giving it a new time stamp.

  3. Do the copy again using /XO. The new time stamp on the file in NEWDIR remains.

  4. Do the copy again using /XN. The new time stamp on the file in NEWDIR reverts.

| improve this answer | |

Use the robocopy tool with the /xn switch. I believe Server 2008 comes with robocopy as standard now.

/XC :: eXclude Changed files.

/XN :: eXclude Newer files.

/XO :: eXclude Older files.

/XX :: eXclude eXtra files and directories.

/XL :: eXclude Lonely files and directories.

/MOV :: MOVe files (delete from source after copying).

/MOVE :: MOVE files AND dirs (delete from source after copying).

so the command will be something like


this will move over all the old files but wont overwrite new ones

You can always use the /L switch to do a dry run this will show you what will happen without actually do anything. Some things may be different on 2008, I am using the XP version.

| improve this answer | |
  • After testing a little it seems that when files are newer on the dest than the source it puts them as older? So maybe XO? – Oskar Kjellin Mar 19 '10 at 9:26
robocopy %Files% %Bak% /E /ZB /MOVE /IS /COPY:DATSOU

Not only do you need /MOVE, you need /IS (Include Same) files.

Otherwise Robocopy never copies the file over when it sees the same file is in both locations.

If you tell it to "Include Same" it sees the same file in both locations, and still copies the file over from source anyway, AND deletes it from source like it's supposed to.

| improve this answer | |

robocopy is good, but I have found that the /move option doesn't appear to work if the file already exists in the target. The /IS and /IT flags are meant to sort this out, but they don't for me, robocopy just ignores them (ymmv). As a workaround, you can create a new destination directory and then move that across to the main target area when the copy is finished.

| improve this answer | |

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.