Wednesday, November 12, 2008

Unstoppable File Copying With Robocopy

Who Is This Handsome Helper?

Robocop...really has nothing to do with robocopy, except that they both never quit and neither of them are very entertaining to watch.If you've never heard of Robocopy (Robust File Copy) you're missing out. When it comes to reliably coping files over an unreliable network, there's no better tool. In fact Robocopy just recently saved my bacon, which is why I'm writing this in the first place.

Originally distributed with the Windows 2003 Resource Kit, Robocopy is now available on Windows XP, Vista and Windows 2008. It's worth mentioning that Robocopy isn't anything like RoboCop, they just sound the same, they both never quit and neither of them are very entertaining to watch (boo-yeah!).


  • Relentless - By default if Robocopy fails (ie. your network connection cuts out) it will retry every 30 seconds until it's tried to copy the files 1 million times, if there's even a remote possibility of getting that file over the wire, it will get there. Given good uptime, odds are that your source machine will die from hardware failure before Robocopy has stopped trying to deliver your file. I dream of a world where USPS had this kind of stamina.
  • Resumable - You can throw down the /Z switch and files will pick up right where they left off. Don't believe me? Try the following; start copying a large file over the network (with Robocopy and the /Z flag) and then toy with Robocopy by unceremoniously pulling out the Ethernet cable. Robocopy will first throw an angry error and then relentlessly retry every 30 seconds until either your file has been copied or you've gone Office Space on the source machine (there's no switch to defend against that). Plug the cable back in and voila, the file automagically resumes. Trust me, this trick is great at cocktail parties and a smash hit with most women. It's worth mentioning that resumable copying does happen a little slower (30% slower in my tests).
  • Replication - Robocopy is exceedingly good at replicating/syncing directory structures. There's never been an easier way to mirror directory structures or file systems.
  • Others - There's a bunch of other features like decent logging, a User Interface if you don't like reading instructions, scripting, mirroring file ACLs, etc...


My only wish is that I could get this utility to call some code once it's done (for notification). Yes I could use a process or file watcher but I'd still like something a little cleaner. I feel like I'm being left in the dark. Maybe that's the very nature of fire and forget...I shouldn't need a notification.

Use It

So next time you're trying to move a lot of files over the wire consider using a utility that is specialized with this very same problem. I've seen (and written) a lot of code that tries to be smarter than it needs to be, none of it has had the effectiveness or cost of ownership of this precious little utility. I wish on you a buggy network, but great file copying.



Ryan said...

If you're pushing a file to a machine and don't want to keep checking the transfer progress, Robocopy sets the "Date Modified" at 1/1/1980 5pm until the transfer is finished, even if the transfer is interrupted, it'll stay at 1980 until the the file is complete. Pretty handy if you star a transfer for someone, they can just check the destination file to see when it's done! (the /ETA switch is pretty cool too...)

Tyler Holmes said...

Nice moves Ryan, thanks for the tip!

Anonymous said...

Hello. AC here. Stumbled across this post via DZone.

"My only wish is that I could get this utility to call some code once it's done (for notification)."

You could wrap it in a batch file. You could call something simple like this with the same params you use when you call robocopy:

robocopy %*
if "0"=="%errorlevel%" (
:: notify success here
) else (
:: notify failure here

There are other ways to do it but I shy away from cleverness.

Tyler Holmes said...

Thanks AC (Andrew Connell mayhaps?). I'll give it a try and let you know.


Mike said...

I'd like to see a utility like robocopy that can skip files on an error, complete the rest of the job, then retry the errors for a specified number of times. Anybody have any suggestions?

Tyler Holmes said...

Hey Mike,

I found these suggestions on stack overflow ( You could also potentially try tera copy (

Good luck,

Som DT. said...
This comment has been removed by the author.
FoxTwo said...

You can stick Robocopy into a batch file and below the robocopy line in the batch file, call your other utilities or programs after it's done.

I have "shutdown -s -t 0" right after robocopy is done with my weekly backups to shutdown my PC :)

Jahid Hasan said...

GSCopy Pro v6.0 (RoboCopy Alternative) with Open File Agent
GSCopyPro is a single command-line tool (CLI) that can copy, replicate and move files from one folder to another. This folder can be on the same machine/ server or another server elsewhere. What makes GSCopyPro stand out from other competitors is the fact it works on 32-bit as well as 64-bit systems and has no restrictions. It can easily be scheduled to run as a scheduled task and fully automated. GSCopyPro also comes with an open file agent which can copy files that are locked/ opened by other processes. This feature is supported in all windows versions from widows XP/ 2003 and later.
Go To:>>

wahid said...

I suggest to try "Long Path Tool" program. It’s really work for me.