Merge two folders with a lot of sub folders and files

I have a situation where there are two folders that need to be merged to one.  The folders are about 8gig in size and contain many levels of sub folders with documents and some images.  The documents are going to be mostly xls, xlsx, doc, docx, ppt, txt, pdf, jpg.

Many of the files are duplicates although one folder may have a more recent document.

Folder A
-- SubFolder A.1
---- SubFolder A.1.1
------ Document A.1.1  somefile.docx last mod 6/12/2015 3:45pm
-- SubFolder A.2
---- SubFolder A.2.1
------ Document A.2.1  somefile.docx last mod 2/21/2015 10:21am

Folder B
-- SubFolder B.1
---- SubFolder B.1.1
------ Document A.1.1  somefile.docx last mod 1/1/2015 1:20pm-- SubFolder A.2
-- SubFolder B.2
---- SubFolder B.2.1
------ Document B.2.1  somefile.docx last mod 6/5/2015 12:53pm

This is on Windows Server 2008

My goal is to Merge everything in Folder B to Folder A where only folders and files get added to A from B that are not in A and only files from B get copied to A if they are newer than in A

Am I better off writing a vbscript or using something like RichCopy?
LVL 57
Scott Fell, EE MVEDeveloper & EE ModeratorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The built-in robocopy should be able to do that.
robocopy.exe "F:\older\B" "F:\older\A" *.* /s /xo /r:0 /np /tee /log:"C:\Temp\robocopy.log" /L

Open in new window

/s: recurse Subfolders
/xo: eXclude Older files (don't copy older files over newer files)
/r:0 no Retry (usually not necessary in a LAN)
/np: No Progress (control characters make the log file hard to read)
/tee: output to console and log
/L: test mode; only Log what would be copied; remove this to run the copy for real.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
XCOPY is more than good enough too and can be less likely to cause issues as it can't possibly do any deleting due to incorrect settings for instance.

xcopy /d /s /-y /c /z x:\FolderB\*.* y:\FolderA

The /d copies if newer or does not exist
Adding /L will test but not copy any files.

If you also want hidden, system files or to overwrite read-only etc. can use the other options available on xcopy but above would do most.

Scott Fell, EE MVEDeveloper & EE ModeratorAuthor Commented:
Thank you.  I am going to give this a try now.
Scott Fell, EE MVEDeveloper & EE ModeratorAuthor Commented:
I used the robocopy, worked perfectly.  I can see the xcopy would be a solution as well.  Thank you both for answering!
Steve KnightIT ConsultancyCommented:
Would use robocopy myself too generally for the logging so agreed!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.