Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

robocopy syntax

Posted on 2014-01-22
7
Medium Priority
?
513 Views
Last Modified: 2014-01-24
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
Comment
Question by:hrolsons
  • 3
  • 3
7 Comments
 
LVL 11

Expert Comment

by:epichero22
ID: 39801718
robocopy *f.jpg c:\ e:\ /E

*Edit: Do you know if the files in the destination are newer or older?
0
 

Author Comment

by:hrolsons
ID: 39801747
The files in the destination should be newer.
0
 

Author Comment

by:hrolsons
ID: 39801758
I was reading here:

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

That I need to do 3 more switches.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 56

Accepted Solution

by:
Joe Winograd, EE MVE 2015&2016 earned 2000 total points
ID: 39801760
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
 

Author Comment

by:hrolsons
ID: 39801798
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
 
LVL 56

Assisted Solution

by:Joe Winograd, EE MVE 2015&2016
Joe Winograd, EE MVE 2015&2016 earned 2000 total points
ID: 39801806
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
 
LVL 56

Expert Comment

by:Joe Winograd, EE MVE 2015&2016
ID: 39801817
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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
Unable to change the program that handles the scan event from a network attached Canon/Brother printer/scanner. This means you'll always have to choose which program handles this action, e.g. ControlCenter4 (in the case of a Brother).
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question