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

Determining If a Drive Should be Defragmented

Disk fragmentation is one of those things which, if severe, can adversely affect your system's performance. This tip ...

Discover More

Viewing Event Logs

Event logs are automatically maintained by the operating system. By periodically viewing them, you'll have a better idea ...

Discover More

Backing Up Your Files

Performing regular backups of your system offers you peace of mind because you don't have to worry about data loss in the ...

Discover More
More WindowsTips

Creating and Using Compressed Folders

If you're low on disk space but still want to keep your files online, you might consider moving them to compressed ...

Discover More

Using Sync Center

Sync Center is a centralized place where you can deal with your offline files. You can do a manual sync, set up a sync ...

Discover More

How to Change Drive Letters

Windows is quite configurable. It even allows you to change the drive letters associated with your disk drives. Although ...

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 1 + 1?

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