imba22
imba22

Reputation: 649

Copy files to destination folder and also delete any that are not in source folder?

I want to copy the folder Prod from source to destination, however I want to update the contents of destination with the contents of the source.

Prod
|--file 1
|--file 2

Destination:

Prod
|--file a
|--file b

The problem is that since the name of the files are different, when I do copy paste I end up with 4 files: file 1, file2, file a, file b

When I only want the two files from source: file 1 & file 2

Upvotes: 2

Views: 3831

Answers (1)

henrycarteruk
henrycarteruk

Reputation: 13227

I'd use robocopy with the MIR (Mirror) switch, this will copy files/folders and remove anything in destination that does not exist in source.

robocopy C:\source\Prod D:\destination\Prod /MIR

Quote from Technet robocopy wiki:

/MIR specifies that Robocopy should mirror the source directory and the destination directory. Note that this will delete files at the destination if they were deleted at the source.

Upvotes: 4

Related Questions