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.

link|improve this question

feedback

2 Answers

up vote 3 down vote accepted
echo n|xcopy "[source]" "[destinaton]" 

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

link|improve this answer
I found no option to skip if copied files already exist on destination. – awe Jan 17 '11 at 11:34
OK - I did find an option to copy only files with Archive attribute set, and then clear it. This will be sufficient for my use, so I will give you credit for the answer since you pointed me in direction of xcopy. – awe Jan 17 '11 at 11:54
I actually used robocopy instead, as the help for xcopy stated that xcopy is depreciated, use robocopy instead. The option I use to ` copy only files with the Archive attribute and reset it.` exist on both (/M). – awe Jan 17 '11 at 11:58
How does setting setting Archive attribute and reseting it would help ? – nepsdotin Jan 17 '11 at 12:04
This is a batch job that runs a backup thing to copy backup 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 can use this to only copy the ones that hasn't already been copied. Also the xcopy/Robocopy supports copying an entire directory structure (with copy I had to first manually create the directories and navigate to the zip location), so now I can use this to just copy the top level (including all old backups as well), and only the new ones will be copied. – awe Jan 18 '11 at 18:57
feedback

Robocopy - auto skip files already in the destination

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

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.