tags:

views:

2627

answers:

7

By default, copying from the command prompt will prompt you to overwrite files that already exist in the target location.

You can add "/Y" to say "Yes to all" replacements.

But how can you say "No to all" ?

In other words, I want to copy everything from one directory that does not already exist in the target.

The closest thing I see is the XCOPY argument to only copy things after a specific mod-datetime.

A: 

I expect xxcopy has an option for that.

Bingo:

http://www.xxcopy.com/xxcopy27.htm#tag_231

2.3   By comparison with the file in destination

       The switches in this group select files based on the
       comparison between the files in the source and those in
       the destination.  They are often used for periodic backup
       and directory synchronization purposes. These switches
       were originally created as variations of directory backup.
       They are also convenient for selecting files for deletion.

  2.3.1  by Presence/Absence

         The /BB and /U switches are the two switches which select
         files by the pure presence or absence as the criteria.
         Other switches in the this group (Group 2.3) are also
         affected by the file in the destination, but for a
         particular characteristics for comparison's sake.

         /BB  Selects files that are present in source but not in destination.
         /U   Selects files that are present in both source and destination.
Adam Davis
+1  A: 

Depending on the size and number of files being copied, you could copy the destination directory over the source first with "yes to all", then do the original copy you were doing, also with "yes to all" set. That should give you the same results.

tloach
That would give the same result in the destination, but would change the source.
Liam
True, your explanation is better anyway, I'll just go upvote it ;)
tloach
Sweet :) I love when problems can be solved without installing more software :)
Liam
+3  A: 

Here's a workaround. If you want to copy everything from A that does not already exist in B:

Copy A to a new directory C. Copy B to C, overwriting anything that overlaps with A. Copy C to B.

Liam
+3  A: 

Unless there's a scenario where you'd not want to copy existing files in the source that have changed since the last copy, why not use XCOPY with /D without specifying a date?

Kev
+1  A: 

I use XCOPY with the following parameters for copying .NET assemblies:

/D /Y /R /H

/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.

/Y - Suppresses prompting to confirm you want to overwrite an existing destination file.

/R - Overwrites read-only files.

/H - Copies hidden and system files also.

chitza
+1  A: 

You can make a text file with a single long line of "n" then run your command and put < nc.txt after it. I did this to copy over 145,000 instances where "No overwrite" was what I wanted and it worked fine this way.

Or you can just hold the n key down with something, but that takes longer than using the < to pipe it in.

Chris
whoa! almost humorous
kurast
+1 for lolfactor. Also +1 because this is more efficient than Liam's solution which some how got +3...
mlaw
A: 

Thanks Chris! I needed to do this today for 55,000 files, and you saved the time of having to re-copy what had already been done. Tricky, but it works!!

Kara