I need to write an batch script that should copy folders from location A(source) to location B(destination). In location B some of those files and folders already exist, so the existing ones should be overwritten but the other files should be preserved.
I tried to use XCOPY and its arguments to accomplish that, but all I got is that this overwrote entire folders, that is the folder in location B was entirely "replaced" by the same folder in location A, although it's intended to only be merged.
Do you have any suggestions?
I should point out that by this way ca. 18,000 files in 2,500 folders should be merged with an even larger directory (27,000 files in 4,000 folders) which has a very similar structure, taking in account that some of the source-folders need to excluded from the merge. So I guess that file by file operations are not recommended? That's why I tried the "whole folder merge" approach.
Thanks a lot
PS I'm using windows 7, so the merge I'm talking about is the one that you get when copy a folder to a destination which contains the same folder name and then choose "Merge" those folders and "Copy and Replace" for the files.
1 Replies - 4950 Views - Last Post: 16 May 2012 - 10:15 AM
Replies To: batch script - how to merge contents of folders (not just copy)
Re: batch script - how to merge contents of folders (not just copy)
Posted 16 May 2012 - 10:15 AM
I tried xcopy "c:\A" "c:\B" /e /y and it worked fine. Subfolders that were not present in B were created. Files that were in subfolders of B but not A were not touched. Files that were not in B's hierarchy were created. Files that were in both were overwritten with A's version. This is characteristic of a merge.
Page 1 of 1