31

Is it possible to use robocopy to copy only the files that do not exist in destination?

robocopy has a /is (include same files) switch. What I am looking for is an /xs switch. If a file exists in both the source and the destination I don't want it to be copied. The criteria is file name only, regardless of modified day, size, etc. For example, even if the source has a newer file (based on modified date) than the same file in the destination, I don't want it to be copied. Possible to do this? Thanks.

37

Just use the /xc (exclude changed) /xn (exclude newer) and /xo (exclude older) flags:

robocopy /xc /xn /xo source destination 
  • That does not work (at least if you have other options as well - i.e. /b /e /copyall). Robocopy looks at timestamp and I believe even if the last accessed time stamp is different, it will copy. If there is a way, would love to know about it. – user174865 Nov 21 '12 at 2:49
  • The /xn and /xo options should prevent robocopy from copying because of a different timestamp. Worked fine when I tested it. Robocopy does not pay attention to the last accessed timestamp. Your answer will probably be removed (because it isn't an answer) but you can email me if you want to discuss this. – Harry Johnston Nov 21 '12 at 3:41
  • 4
    Use /FFT if you copy between different filesystems (NTFS, FAT). It should prevent Robocopy from thinking that a file is older/newer while it is actually the same date and time. – Martin Oct 22 '14 at 9:44
  • @HarryJohnston, I have a script that runs in a .bat file and it seems to copy the files but overwrites the file in the destination folder. What I want to know is how do I get this script to move the files and in the destination folder add a timestamp as part of the destination file name ? START /WAIT robocopy %EFM_EXPORT% %EFM_TEMP% *.CFX /S /NP /R:5 /W:5 /XX /XD *PR *PA *TA *DC *Bypass /MOV /LOG:%EFM_MOVE% – DJ KRAZE Sep 1 '16 at 16:52
  • 5
    Worth adding the /s switch as well otherwise it won't enter directories if they already exist. – Tom Carpenter Jul 16 '17 at 18:03
-1

If you're copying from left to right, you want to only copy orphaned files on the left to the right side.

I use a pay tool called Beyond Compare that handles these type of scenarios. RoboCopy is great for mapped drives or even UNC paths, but my two use cases involves:

  • FTP to copy new files to my web site
  • move/archive files to DropBox

That, I unfortunately can not do with RoboCopy.

protected by Community Jul 6 '16 at 18:02

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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