Ben_Stanton Posted August 28, 2013 Posted August 28, 2013 Hi guys, This is bit of a difficult one to explain. I want to merge two folders including directory structure and files (even if empty). Essentially, I have two copies of one folder (both taken at different times). A straight copy is out of the equation for obvious reasons. Folder1 has 14 root folders (and then child folders and files within those). Folder2 has some of the same folders/files, but also new ones. Basically, folder1 has some stuff in it, folder2 has some too. Can this be done with robocopy? I also want to keep the data that i'm merging from (not move or mirror). If this can be done, can somebody send some example script as I'm knee-deep in work at moment (aren't we all). Start of term sure does creep up you... Thanks in advance... this has been a real dodo of a couple of days!
Steve21 Posted August 28, 2013 Posted August 28, 2013 I think I get the basics, but say for example folder 1 has DocA in, and folder 2 has DocA in but editted later. Which are you wanting to keep? Steve
Ben_Stanton Posted August 28, 2013 Author Posted August 28, 2013 I think I get the basics, but say for example folder 1 has DocA in, and folder 2 has DocA in but editted later. Which are you wanting to keep? Steve Sorry, I should have said. I want to keep the newer one.
Steve21 Posted August 28, 2013 Posted August 28, 2013 Should simply be: Robocopy C:\SourceDir C:\DestDir /E /XO /E : Copy Subfolders, including Empty Subfolders. /XO : eXclude Older - if destination file exists and is the same date or newer than the source - don’t bother to overwrite it. Example: Directory of C:\SourceDir 28/08/2013 15:03 emptyfolder 28/08/2013 15:03 0 test1.txt 28/08/2013 15:04 0 test2.txt Directory of C:\DestDir 28/08/2013 15:03 . 28/08/2013 15:03 .. 28/08/2013 15:03 0 test1.txt 28/08/2013 15:03 0 test2.txt C:\DestDir>Robocopy C:\SourceDir C:\DestDir /E /XO ------------------------------------------------------------------------------- ROBOCOPY :: Robust File Copy for Windows ------------------------------------------------------------------------------- Started : Wed Aug 28 15:04:33 2013 Source : C:\SourceDir\ Dest : C:\DestDir\ Files : *.* Options : *.* /S /E /COPY:DAT /XO /R:1000000 /W:30 ------------------------------------------------------------------------------ 2 C:\SourceDir\ 100% Newer 0 test2.txt New Dir 0 C:\SourceDir\emptyfolder\ ------------------------------------------------------------------------------ Total Copied Skipped Mismatch FAILED Extras Dirs : 2 1 1 0 0 0 Files : 2 1 1 0 0 0 Bytes : 0 0 0 0 0 0 Times : 0:00:00 0:00:00 0:00:00 0:00:00 Ended : Wed Aug 28 15:04:33 2013 C:\DestDir> It'll overwrite test2 as it's newer than the destination. But test1 is older so ignored. And empty structures get copied etc. That what you mean? Steve
Ben_Stanton Posted August 28, 2013 Author Posted August 28, 2013 Thanks Steve Ha. Well aren't I the div. That wasn't difficult at all. I probably spent longer writing the first post than it would have taken me to do that. Thank you very much. I just tested it on some dummy folders and it seems to have worked. Ben
Steve21 Posted August 28, 2013 Posted August 28, 2013 Hehe. Yeah it only gets more fun with all the extra options, but hopefully that should do what you're after! Steve
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now