Copying Data with Robocopy

Written by Barry Dysert (last updated November 13, 2017)

Robocopy ("Robust File Copy") is a command-line utility that comes with Windows. It offers a great deal more functionality than the familiar COPY command, but of course the additional functionality makes Robocopy a bit more difficult to use than COPY. This tip provides information on some of its more interesting features so that you can begin using it with very little learning curve.

Probably the first thing to recognize is the unusual syntax involved. Robocopy requires at least two parameters, in this order: (1) the source directory, (2) the destination directory. If this is all you specify, the files that get copied default to all. If you want to limit which files get copied, specify a third parameter: the file(s) to be copied. So to copy the files 'A.tmp' and 'B.tmp' from C:\Temp to C:\Temp2, the command would look like this:

C:\> ROBOCOPY C:\Temp C:\Temp2 A.tmp B.tmp

Once you're used to the odd order of the parameters, you can focus on some of the important options available to you. All of the options begin with a slash, and they appear at the end of the command, i.e., after the name of the last file you want to copy. One good option to be aware of is the /E option. This tells Robocopy that it is to copy subdirectories in addition to files. This says to copy the specified files and also copy all of the directories from the source to the target (although the directories in the target will be empty).

Perhaps a more useful option, which in a way extends /E is the /MIR ("Mirror") option. You can create a mirror of the source directory tree (i.e., copy all files and all folders including their files) simply by specifying the following command:

C:\> ROBOCOPY C:\Temp C:\Temp2 /MIR

Note that no files were specified; the default is all files ("*.*").

Another great option, especially if you're copying large files and/or going across a bad connection, is /Z. This causes the copy to be done in "restartable" mode. In other words, if a file is in the process of being copied and the transmission is aborted for some reason, the next time you invoke Robocopy the copy will continue from where it left off rather than starting all over again. You can also have the retries occur at specific intervals by specifying the /R and /W options.

One final option you may find useful is the /MOV option. This effects a move of the files from the source to the destination, i.e., once the file is safely at the destination, the source file is deleted. (The same functionality exists for moving folders — just use the /MOVE option.)

There are a lot more options that can be used for Robocopy. For a complete list invoke it with the /? switch:

C:\> ROBOCOPY /?

 This tip (13222) 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

Using the Snipping Tool

Being able to capture portions of the screen can come in handy for a wide variety of reasons. The Windows snipping tool ...

Discover More

Creating a System Repair Disc

Doing a one-time create of a system repair disk can be worth its weight in gold if you find yourself unable to boot your ...

Discover More

Using Media Player to Burn an Audio CD

One of the many things you can do with Windows Media Player is to burn audio CDs. This tip shows you how.

Discover More
More WindowsTips

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

Changing the Default Program for a File

Files are opened by programs depending upon the file's type. If you want to change this association so that a different ...

Discover More

Illegal Windows Names

When it comes to files and folders and naming them in there are restrictions. Knowing what is restricted will help you ...

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?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


Newest Tips