Windows – win2003 way to copy folders in a smart way

command-line-interfacecopyingwindowswindows-server-2003

I have 2 folders, the first:

C:\folder1
C:\folder1\subfolder\a.txt
C:\folder1\subfolder\b.txt

and the second:

C:\folder2
C:\folder2\subfolder\a.txt

I would like to merge them like so:

C:\folder2
C:\folder2\subfolder\a.txt (folder 2's a.txt)
C:\folder2\subfolder\b.txt

Description of what I want:

Is there a simple DOS command to copy all of the folders, subfolders and files from folder1 TO folder2, but if something exists in folder2 I do not want to overwrite it.
If folder 1 has files that do not exist in folder2, I want them to be copied in.

Note: both folder1 and folder2 share common subfolder names.

Note 2: Folder2 is several TB's so I really have to copy into folder 2. Folder1 is only several GB.

I can't do this in windows explorer because there is no option to say overwrite files? No to all.

Best Answer

Yes, the robocopy.exe resource kit utility I think was made part of the OS with Windows 2003. You can specify all sorts of options as to what gets overwritten or not.

By default, robocopy won't overwrite same files, just newer versions over old - it's a folder syncing tool, mainly.

If you want to avoid any sort of overwrite, this might work,

robocopy C:\FOLDER1 C:\FOLDER2 /e /xc /xn /xo 

where,

/e is copy all subfolders, even empty ones.
/xc is exclude changed files.
/xn is exclude newer files.
/xo is exclude older files.

I recommend you test first with these additional switches,

robocopy C:\FOLDER1 C:\FOLDER2 /e /xc /xn /xo /l /log+:robocopy.txt /np /ndl /tee

where,

/l is just list, don't actually do anything. Remove this switch when you're happy with what robocopy will do.
/log+: appends output to a text file, so you can study it, or /log:, which overwrites the log each time.
/np prevents "% done" progress info in the log.
/ndl is a personal preference for a cleaner log output, but maybe leave this switch out until you're comfortable with how robocopy works.
/tee shows you output on the screen as well as the log.

Related Topic