Using Robocopy to Mirror Directories

Written by Barry Dysert (last updated October 9, 2017)

3

Robocopy is the tool to use when working with entire directories, since that's what it was designed to do. Let's say you want to "mirror" directories, i.e., make two directory trees contain identical files/folders. This is similar to using the /E switch (which is covered under the tip titled "Using Robocopy to Copy Entire Directories") along with the /PURGE switch. (The /PURGE switch tells Robocopy to delete destination files/folders that no longer exist in source.) The shorthand switch to mirror directories is /MIR, so the command to mirror directories is:

C:\> ROBOCOPY C:\Temp1 C:\Temp3 /MIR

This results in the creation of C:\Temp3, and all of the files and folders under C:\Temp1 will be copied to the newly built tree under C:\Temp3. In addition, if C:\Temp3 already existed, any files in its tree that are not in the C:\Temp1 tree will be deleted from the C:\Temp3 tree.

 This tip (13197) applies to Windows 7, 8, and 10.

Author Bio

Barry Dysert

Barry has been a computer professional for over 35 years, working in different positions such as technical team leader, project manager, and software developer. He is currently a software engineer with an emphasis on developing custom applications under Microsoft Windows. When not working with Windows or writing Tips, Barry is an amateur writer. His first non-fiction book is titled "A Chronological Commentary of Revelation." ...

MORE FROM BARRY

Adding and Removing Desktop Widgets

You can add and remove widgets on a whim. Both operations are just a couple of mouse clicks away. Removing a widget from ...

Discover More

Permanently Deleting a File

If you have a file that you're sure you want to permanently delete (instead of having it go to the Recycle Bin) it's an ...

Discover More

Getting Rid of a Built-in Windows Library

Most people like the Library feature of Windows, but for those who don't, this tip explains how to get rid of a built-in ...

Discover More
More WindowsTips

Getting Rid of Hidden Thumbs.db Files

A hidden file that the system uses to speed performance of your viewing folders containing pictures is called Thumbs.db. ...

Discover More

Moving Files or Folders

A common operation within Windows is to move files and folders from one location to another. Here are the two major ways ...

Discover More

Repairing Your System Using a System Repair Disk

If your system gets into a state where it cannot be started normally, this tip presents you with options of how you can ...

Discover More
Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 2?

2018-03-02 23:45:56

george renee

Just to share one thing I read on a Microsoft TechNet:
Although useful in some scenarios, using /Z switch makes copying much slower.
"Copying files in restartable mode is about 6x slower over a network than in normal or backup mode due to the necessary management overhead."
..I use GS RichCopy Enterprise which has features like copying long file path names, copying NTFS file permissions and is not too costly..


2018-02-12 13:08:43

vikas

use robocopy


2017-10-10 11:55:22

Len Richard

I didn't understand exactly what mir did. I copied around 300 cds to an external drive, then delete them from the folder they were in, so I could store more there for backup. When I again backed up this folder to my external drive it wiped out everything i had previously backed up. I did a googlie on this and discovered I was not the only person who got screwed. There needs to be a clear Warning Visible that nobody can miss explaining this. I tried 10 free recover tools, none worked. I finally found a trial version of a recover software, it worked and it cost be 70 bucks to purchase it. It was either that or lose everything. Nice to notice you have this explained. Too bad every other person offering advice doesn't.


Newest Tips