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 ?
Who is Participating?
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

Bill PrewCommented:
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

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.


Also a similar thing for /mov /move needing to have the extra /s or /e /s
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
Glad to help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.