robocopy syntax

Can someone help me write a robocopy statement that will copy any file named *f.jpg on the C:\ drive to the E:\ drive, not overwriting anything.
hrolsonsAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Joe Winograd, Fellow&MVEConnect With a Mentor DeveloperCommented:
robocopy c:\ e:\ *f.jpg /s /xc /xn /xo

The /s gets all non-empty subfolders (if you want empty ones, make that /e) and the /xc /xn /xo is a cutesy way not to overwrite. I've attached the full syntax of Robocopy so you can see why those three options result in no overwriting. Regards, Joe
robocopy-help.txt
0
 
epichero22Commented:
robocopy *f.jpg c:\ e:\ /E

*Edit: Do you know if the files in the destination are newer or older?
0
 
hrolsonsAuthor Commented:
The files in the destination should be newer.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
hrolsonsAuthor Commented:
I was reading here:

http://stackoverflow.com/questions/4228807/copy-files-w-o-overwrite

That I need to do 3 more switches.
0
 
hrolsonsAuthor Commented:
So I'm still unclear if:

robocopy c:\ e:\ *f.jpg /e

is the same as:

robocopy c:\ e:\ *f.jpg /e /xc /xn /xo

Or is it just redundant?
0
 
Joe Winograd, Fellow&MVEConnect With a Mentor DeveloperCommented:
No, it's not the same. The  /xc /xn /xo switches are effectively what implements no-overwrite. Without them, it will overwrite. Here's what those options mean:

/XC eXclude Changed files.

/XN eXclude Newer files.

/XO eXclude Older files.

So if you exclude changed, newer, and older files, it won't overwrite anything. It will copy only files that aren't already there, which I believe is what you asked for. Regards, Joe
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
Actually, you could do just /xc. In other words, detecting a changed file means, by definition, that the same file exists in both the source and destination folders...otherwise, it wouldn't be changed! Run some experiments on small sets of files to see what happens.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.