[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 530
  • Last Modified:

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.
0
hrolsons
Asked:
hrolsons
  • 3
  • 3
2 Solutions
 
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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Joe Winograd, EE Fellow 2017, MVE 2016, MVE 2015DeveloperCommented:
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
 
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, EE Fellow 2017, MVE 2016, MVE 2015DeveloperCommented:
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, EE Fellow 2017, MVE 2016, MVE 2015DeveloperCommented:
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now