Windows – How to copy files from A to B, only including files that exist in B

file-transferrobocopywindows 7

I'm on Windows 7 Professional, and this is my scenario :

Folder "Asd" (C:\)              Folder "Asd" (D:\)
File 1                          File 1 
File 2                          File 3 
File 3                          File 4
File 4
File 5

I'd like to select the folder on C:\ (without selecting each single file, of course) and copy it over the same folder on D:. Usually, it will copy all files. But what I'm looking for is to copy only files (from C:) that are contained on folder d:.

So in my case I'd like to replace only File 1, File 3 and File 4.
File 2 and File 5 must be ignored.

Is it possible?

Best Answer

When you want to copy, robocopy always has the right switch to do it.
Here you want the /XL switch to exclude “lonely” files:

robocopy C:\ D:\ /S /XL

This will work with files or folders.

Related Question