Copying Data with Robocopy

by Barry Dysert
(last updated September 1, 2014)

2

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 and 8.

Author Bio

Barry Dysert

Barry has been a computer professional for over 30 years, working in different positions such as technical team leader, project manager, and software developer.  He is currently a senior software engineer with an emphasis on developing custom applications under Microsoft Windows. ...

MORE FROM BARRY

Understanding Windows Firewall

There are a lot of malicious users on the Internet who are trying to break into other people's systems. One way to mitigate ...

Discover More

Displaying Hidden and System Files in a Folder

Files (and folders) can be marked hidden so that you don't see them in Windows Explorer. This tip tells you how to configure ...

Discover More

Microsoft Edge Extensions

Like all good browsers, Microsoft Edge supports extensions. Although getting and using them may be a little rough around the ...

Discover More
More WindowsTips

Using Windows Easy Transfer

If you ever want to copy user accounts, documents, pictures, etc., from one computer to another, you'll find that Windows ...

Discover More

Deleting Files or Folders

Part of managing the files and folders on a system is the need to occasionally delete them. Here's a quick discussion on a ...

Discover More

Customizing File Explorer's Display

File Explorer is a powerful utility to use for navigating among your files and folders. And it can be customized a great deal ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. 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 two minus 2?

2014-09-06 23:20:46

Andrew G. Plourde

Well, this is not actually a comment on the topic of Robocopy, but I don't know how to open up a new topic. Anyway, I'm sure it will get to the same place.

I seem to have a habit of hitting the Caps Lock key (which I seldom use) instead of the Tab key (which I use often).

Is there any way to activate Caps Lock only after a second click?

Andrew


2014-09-06 23:12:02

Andrew G. Plourde

While I was typing my name for this comment, I was interrupted by a request to sign up for the newsletter, which I am clearly getting, and have been for a month or so. And you might want to check the timing of your six-month clock.

Andrew

The original question that I had will follow soon.


Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WindowsTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.