ROBOCOPY -- keep existing folders ?

I currently have three folders on my "H" drive
  ** H:\a\.........
  ** H:\b\.........
  ** H:\c\.........

I then do robocopy G:\ H:\ /s /e /copyall /mir /v /tee /r:0 /log:robocopyNOTES.txt and all of the above folders get deleted, even when I do NOT have these folders on the G drive

How can I copy the G drive folders to the H drive, keeping existing H drive folders as-is if they do not have the same name as G drive folders ?
finance_teacherAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Ben Personick (Previously QCubed)Lead Network EngineerCommented:
On mobile, but the issue is you have MIR which will delete items not in the source.

robocopy G:\ H:\ * /s /e /copyall /v /tee /r:0 /log:robocopyNOTES.txt 

Open in new window

0

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
Bill PrewIT / Software Engineering ConsultantCommented:
Following up on Ben's comment, the /MIR is the problem.  Note that /MIR means /E /PURGE, and the /PURGE option is what is removing those files/folders from the destination that do not exist in the source.  So just /E instead of /MIR gets it done for you.  Also not, /S and /E are somewhat contradictory, if you have /E then you don't need/want /S.  It may work fine, but it reads a little confusing to me.  You can omit the file specification as you did, *.* will be used as the default.  So I would end up at:

robocopy G:\ H:\ /e /copyall /v /tee /r:0 /log:robocopyNOTES.txt

Open in new window


»bp
0
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
Hey Bill, just a note, I have found that just using /e does not work in some versions of robocopy and /s /e works as expected every time.

For some reason on some versions of robocopy /e /only/ copied the empty folders and 0 byte files.

Never looked into it enough to figure out which versions are affected myself but I thought you might be interested in my observations on that.

  YMMV.

Also a similar thing for /mov /move needing to have the extra /s or /e /s
1
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
Glad to help!
0
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
Microsoft DOS

From novice to tech pro — start learning today.