Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Having XCopy copy a file and not overwrite the previous one if it exists (without prompting)

Tags:

xcopy

I'm sending a commands to a remote computer in order to have it copy a file. I want the file to be copied, but not to overwrite the previous file with the same name (if it exists). I also need the command to run without any prompts (xcopy likes to prompt whether the target name I've specified is file or directory, and it will also prompt about overwriting a file).

like image 510
Vic Avatar asked Mar 01 '11 09:03

Vic


People also ask

Does xcopy Skip existing files?

xcopy cannot be configured to SKIP existing files, so you should copy using "robocopy".

How do I copy files without replacing existing files?

If you are copying files using drag-drop or copy/paste, you may simply choose “Skip this file” or “Skip these files” option to not overwrite the files that are already existed at the destination folder. Or, if you are using command line copy, you can answer N to bypass these files that are already existed.

How do I use xcopy without prompt?

Press D if you want the file or files to be copied to a directory. You can suppress this message by using the /i command-line option, which causes xcopy to assume that the destination is a directory if the source is more than one file or a directory.

How do you copy and not replace?

All you have to do is hold down the Shift key while you click on no. It has the same effect as saying No To All which means that the copy process from that moment on will automatically select no if a duplicate file is found in the destination directory.


1 Answers

I have good results with xcopy /d.

It will copy NEWER files, and since we can assume that existing files have same time-stamp, you will copy only files that don't exist.

like image 86
Daniel Mošmondor Avatar answered Sep 16 '22 11:09

Daniel Mošmondor