Top Nav

Automatically Mirror Files in Windows to a Network Drive with Robocopy

robocopy as synctoy 2.1 alternativeMy home has many computers and many screens, but just one central library of photos, music and videos. My main computer stores all my multimedia (and the backups). But rather than keeping my main computer on at all times (it’s a power hungry mid-tower), I mirror my photos and videos to a network drive that’s plugged into my router. Originally, I was using SyncToy to keep my main multimedia library in sync with the network drive library.  But for inexplicable reasons, SyncToy has been running monstrously slow ever since I upgraded to Windows 7 and Windows 8. Since Microsoft stopped supporting SyncToy about four years ago, it’s unlikely that it’ll be fixed. So, I’ve started using Robocopy instead. And so far, it works great.

I can sync a folder pair consisting of my main photo library and a folder on my network drive. And like with SyncToy, Robocopy will also delete files on the network drive that no longer exist in my collection. Best of all, Robocopy is free (it comes built-in to Windows).

As a quick aside, I want to note that I tried FreeFileSync as an alternative to SyncToy. Aside from not working particularly well, FreeFileSync came bundled with some nasty adware toolbar that was an absolute pain to uninstall. Do not use FreeFileSync.

Robocopy is a command line tool. To mirror a folder to another folder (in my case, the folder on my network drive), use the following switches:

robocopy source_directory target_directory /MIR

Replace source_directory and target_directory with the appropriate folder paths. Note that you’ll have to wrap it in quotes if there are spaces in the folder path.

Related Article:  How to Install Windows 8.1 from a USB Flash Drive [Updated]

That’s the basic command you’ll need. It only has one switch: /MIR. /MIR is a combination of the /e and /purge switches, which, collectively, copy all subdirectories (including empty subdirectories) and delete files and directories that no longer exist in the source directory. /MIR also overwrites the directory security settings (unlike /e) if the directory already exists.

Simply type the above command into cmd.exe to make it happen.

automatically mirror photo library

The progress of the file copy will be shown in the command window. Afterwards, you’ll get a summary of the files transferred. Here, you’ll see that 2 files were copied and 1 was deleted because it didn’t exist in the source directory. Only 1 directory was copied because the other directory was the root, which already existed.

robocopy to network drive /mir

To save yourself the trouble of typing that in each time you import photos to your library, you can copy and paste the command into Notepad and save it with the .bat extension.

robocopy batch file

Then, all you have to do is double-click it to run it.

robocopy windows task scheduler

With a batch file, you can also automate it to run once a week, daily, etc. similar to my earlier tip on how to automatically wake and sleep your computer using Windows Task Scheduler. Just sub out the wake.bat and sleep.bat for mirror.bat.

Other Switches and Tweaks

There are two other switches I use with my Robocopy mirror batch file. The first is the /z switch. This enables Restart mode, which lets you resume a large transfer if it’s been interrupted. With large movie files, this may come in handy. But with network drives, it does slow things down a bit.

Related Article:  Fixing Windows 7: Enable Hibernate Mode

The other one I use is /LOG. This writes the status of the transfer to a log file, rather than displaying it in the command prompt. This is handy when the transfer runs automatically when I’m away, so I can go back and view it. I save the log in my Dropbox folder, so I can view it from my phone or another computer to see if the transfer occurred.

My entire batch file looks like this:

robocopy “E:\Storage\Photos and Videos” “Z:\photos and videos” /MIR /Z /LOG:mirror.log


Overall, Robocopy has been working well for me. It keeps my files in sync so they are available to all the devices on my network. And it seems to be considerably faster than SyncToy. Usually, I sync right away whenever I do an import, but if I forget, it runs once a day at 5AM (which is about 15 minutes before I sit down at my computer first thing in the morning).

Also, this will work much better for you if you use one directory for your photos and videos. If you have multiple directories, things can get a little more complex. But it could be as simple as running multiple Robocopy commands (one for each folder pair to keep in sync).

What do you use to mirror files to your network drive? Let us know in the comments!

More Reading:

, , ,

20 Responses to Automatically Mirror Files in Windows to a Network Drive with Robocopy

  1. Harv April 15, 2013 at 3:18 am #

    Doesn’t work as expected. I put the command to test a small directory in a batch file. After the first run I ran the same batch file multiple times without changing anything. It still copies the files and reports them as Older or Newer. I expected the files to be bypassed after the first run.

    • Jack Busch April 15, 2013 at 7:00 pm #

      Hi, Harv – Not sure why you are experiencing that. I run it every morning and I get lots of skipped files. See my last report:

      Total Copied Skipped Mismatch FAILED Extras
      Dirs : 793 2 791 0 0 0
      Files : 16711 46 16665 0 0 0
      Bytes : 118.058 g 279.28 m 117.785 g 0 0 0
      Times : 0:09:49 0:06:24 0:00:00 0:03:24

      Are you using all the switches?

      robocopy “E:\Storage\Photos and Videos” “Z:\photos and videos” /MIR /Z /LOG:mirror.log

      • Harv April 16, 2013 at 3:55 am #

        Here’s what I get after repeat runs of the batch file with no changes. The “Newer” is sometimes reported as “Older”.

        F:\Marcs Documents\PC Stuff\macros>robocopy “f:\marcs pictures\2013 pictures\Gracienne” “t:\2013 pictures\Gracienne” /MIR

        ROBOCOPY :: Robust File Copy for Windows

        Started : Tuesday, April 16, 2013 6:49:11 AM
        Source : f:\marcs pictures\2013 pictures\Gracienne\
        Dest : t:\2013 pictures\Gracienne\

        Files : *.*

        Options : *.* /S /E /DCOPY:DA /COPY:DAT /PURGE /MIR /R:1000000 /W:30


        5 f:\marcs pictures\2013 pictures\Gracienne\
        100% Newer 17.3 m Moviea.wmv
        99% Newer 138242 photo.JPG
        Modified 117789 photoa.JPG
        99% Newer 87243 photob.JPG
        99% Newer 430604 tthotoa.JPG


        Total Copied Skipped Mismatch FAILED Extras
        Dirs : 1 0 0 0 0 0
        Files : 5 5 0 0 0 0
        Bytes : 18.08 m 18.08 m 0 0 0 0
        Times : 0:00:09 0:00:09 0:00:00 0:00:00

        Speed : 2106881 Bytes/sec.
        Speed : 120.556 MegaBytes/min.
        Ended : Tuesday, April 16, 2013 6:49:20 AM

        F:\Marcs Documents\PC Stuff\macros>pause
        Press any key to continue . . .

  2. CapInDFW April 15, 2013 at 1:19 pm #

    Very slick. I had no idea robocopy existed, let alone how powerful it is. I was messing around with xcopy and various applications of questionable worth (FYI – free of charge doesn’t necessarily make it worth it). Robocopy is just what I’ve been looking for to sync my media!
    Thanks for the tip! G+ and FB like

  3. OFS May 22, 2014 at 9:58 am #

    FreeFileSync DOES WORK, and works very well. Just be careful during install so that you don’t install the crapware.

  4. Sean June 15, 2014 at 12:08 pm #

    I ended up googling my way here after downloading FreeFileSync (FFS – ha!) and seeing the crapware included with it (luckily I spotted it before installing). It is not possible to install it without also installing the junk – the three options are…

    1. Install FFS and Linkey, and set homepage, and a load of other stuff to it
    2. Install FFS and Linkey, but don’t set homepage and other stuff to use it (BUT STILL INSTALL IT!)
    3. Install nothing – neither FFS or Linkey

    The installer is clearly designed to fool the skim-reader into thinking that option 2 (custom) is to install FFS but not Linkey – it is not. Always read every word of the installer for free software!

    But robocopy looks absolutely perfect – thank you very much for the guide.

    • Steve Krause June 15, 2014 at 2:07 pm #

      You bet Sean. Yeah, Robocopy just gets it done. There is so much Junkware out there now it’s annoying. I installed IMGBURN on a PC I built on Saturday and only by clicking “Advanced Install” did I see they were also adding in a bunch of JUNK along with the App I wanted to install…..

      So good FYI on the FFS junk. Good reminder for everyone to READ THE FINE PRINT!

      Thnx for reading my blog.


    • Sean July 19, 2015 at 5:19 am #

      FreeFileSync definitely *CAN* be installed without crapware, and very easily, at least as of June of 2015. Only one clearly-identified box to un-check.

  5. Andy Bussieres September 14, 2014 at 9:12 am #

    I’ve set it up and tested it on a single network directory – with a .bat file much the same as yours. Works like a charm. Always was a fan of its predecessor – xcopy. Follows the KISS rule. I have two 6TB My Cloud drives – one for data – one for backup. Considered the WD Mirror drive – but prefer fully independent units. Hope it doesn’t take too long to go through the directory structure after the initial copy. Thanks for the post.

  6. Tony S. January 10, 2015 at 2:08 pm #

    so, I would like a robust backup of some files that get edited on multiple machines, will this work? I don’t know if you know the electric sheep screensaver, but figured it would be a good set of test files where is is continually downloading and making new ‘sheep’ it will also delete old sheep based upon a file size. Which simulates my house where files do accidentally get deleted. would be nice to add something like the Apple Time Machine Backup into the works.

    –file name
    robocopy “C:\ProgramData\ElectricSheep\content” “\\WDMYCLOUD\SmartWare\Electric Sheep” /MIR /Z /LOG:mirror.log
    robocopy “\\WDMYCLOUD\SmartWare\Electric Sheep” “\\FRED-505\ElectricSheepContent” /MIR /Z /LOG:mirror.log
    robocopy “\\FRED-505\ElectricSheepContent” C:\ProgramData\ElectricSheep\content” /MIR /Z /LOG:mirror.log

  7. Bill November 13, 2015 at 3:08 pm #

    I’m stumped how to get RoboCopy to work under Win7. I’ve devolved down to the simplest case I can think of and it doesn’t work. First I execute:

    Copy c:\SharedData\Test.txt c:\Junk\Test.txt

    This works fine. Then I simply add Robo to the front and try to execute again:

    RoboCopy c:\SharedData\Test.txt c:\Junk\Test.txt

    Win7 complains “ERROR 123 Accessing source directory. Filename, directory name or volume label syntax is incorrect.”

    Any idea what I’m doing wrong? It seems too simple to be wrong, but…

    • isaiah November 23, 2015 at 3:07 pm #

      are you appending the line with “/MIR” ?

      robocopy “E:\Storage\Photos and Videos” “Z:\photos and videos” /MIR


  8. TravisRiggs January 10, 2016 at 3:55 pm #

    I am trying to use this for a networked drive, however I want to copy all of the sub-directories as well. Where “N” is my network and “L” is my local machine. My N drive has directories that go through multiple levels (e.g. N\Cases\Case Number\Emails\) robocopy doesn’t seem to create directories or subfolders.

    • TravisRiggs January 10, 2016 at 4:17 pm #

      Actually I wasn’t being patient enough – it is working great now and I am working on scheduling automatic updates. A question on the batch file: could it be setup to run every hour? In the event I am disconnected from my network (I’m using a laptop and I often travel for work) is there a way to pause the scheduled task without deleting it?

  9. Nicole March 23, 2016 at 4:35 pm #

    my batch file doesn´t work! I don´t know what I´m doing wrong… 🙁

    • Andrew April 3, 2016 at 5:05 am #

      Here’s mine. If you post your batch file, we can try to figure out why it is not working.

      robocopy “\\WDMYCLOUD-6TB1\Public\Shared Videos\Z” “\\WDMYCLOUD-6TB2\Public\Shared Videos\Z” /copy:dt /mir /z /log:C:\Users\Andrew\Desktop\mirror.log /tee /np

  10. Paul June 11, 2016 at 11:57 am #

    @Bill: robocopy is a tool meant for syncing folders, but you are trying to use it to copy individual files. If you remove both occurrences of “Test.txt” in your example then you should find that it works 🙂

    • Bill June 12, 2016 at 7:12 am #

      Thanks for that. I went back to look at the system help for RoboCopy and it’s ambiguous just mentioning “source” and “destination”, but not file or directory.

      But it does seem to just work for directories.

  11. Juan June 15, 2016 at 1:06 pm #

    Hi, mine is not working either…I created two small folders to try it out .

    Here it is, as one of the folder path does not have spaces I did not wrap it in quotes.

    robocopy C:\Users\s176026\Documents\Screenshot-Confirmations “C:\Users\s176026\Desktop\test\test once more” /MIR /Z /LOG:mirror.log

    Is this correct?

    Thank you in advance

Leave a Reply