Batch file to run xcopy without overwriting existing files

Eae picture Eae · Jul 11, 2013 · Viewed 76.2k times · Source

I need my program to run:

xcopy s:\* z:\ /E

When xcopy runs, it will prompt if a file needs to be overwritten, so I want the batch file to answer no in all cases to the prompt.

How can I accomplish this?

Answer

Jeff Fischer picture Jeff Fischer · Dec 22, 2014

I almost overlooked this in the switches myself. I was aided by an Experts Exchange article.

Here is the switch of significance:

/D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.

The "If no date is given" portion is of particular importance. This doesn't exactly answer the "without the overwriting existing files" question, but it does answer it if the existing file's time stamp of the source file is not newer than the destination file.

Close enough for government work.