4

I know that the copy command has an option to automatically replace a file if it already exists, but I want to know if it is a way to copy the files only if they not already exist (/Y). I do not know the actual file names in the batch code, as I copy from the source using wildcards in the copy command:

copy *.zip c:\destination

The reason I want this instead of automatic overwrite is that the files are large, and to skip existing would save a lot of execution time. It is done over a network share, so copying this amount of data can take a while...

Additional info:
This is a batch job that runs a backup thing to copy zip files from my computer to a shared server, and in case the batch job didn't finish for some reason (only some of the zip files copied), I need to run the batch again, but only for those zip files that wasn't copied before.

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
awe
  • 1,119

4 Answers4

4

This command solved this for me:

XCOPY *.ZIP /D C:\DESTINATION
Stefan Seidel
  • 10,855
3
echo n|xcopy "[source]" "[destinaton]" 

Check out the various arguments for xcopy to tailor for your particular use

Uninspired
  • 1,183
0

Robocopy - auto skip files already in the destination

ROBOCOPY \some\folder c:\destination *.zip /S

0

The problem is solved by using robocopy and use the /M option to copy only files with the archive flag set, and then clear it.

robocopy /M *.zip c:\destination

In this article on wikipedia you see that this is actually very similar to what the archive flag is intended for in the first place.

awe
  • 1,119