In this article you’ll learn how to use Robocopy in Windows 7: What it is, how to use its switches, and the difference between other file copy utilities, along with a really brief history of the tool.
You may find that copying or moving by grabbing & dropping data from source to a destination folder seems OK in various scenarios, but when it comes the time to do serious heavy-duty file copying, you need a file management tool that can do a better job than just “OK”. Sure there are alternatives like, for example, TeraCopy which can do the copy tasks a little bit easier, but you still can do better.
Robocopy (or Robust File Copy) is a command line-based file management tool that is more powerful and flexible than any other copying tool you’ve ever used before. This tool was introduced back in Windows Server 2003 in the Resource Kit and then it was included on every version of Windows 7.
The “Robust File Copy” from Microsoft shines in the ability to preserve all NTFS attributes found in files and folder, and in the capability to mirror all data structure across different locations such as in local hard drives or over the network. It also provides something you won’t find in Windows Explorer, that is the ability to recover automatically from interruptions like network outages and finishing the task.
As typing commands is a must with this tool, if you used in the past Copy and Xcopy, you have an idea of how all this works, but the syntaxes are completely different. One of the differences is that Robocopy was built to work mainly with two folders (source and destination), and file names are optional parameters.
This file management tool built-in Windows 7 and above releases comes with tons of switches that, when applied correctly, can save you a lot of time and prevent many issues. The command below is an example of a basic syntax:
robocopy source destination [file [file]...]
Source and destination can be a mix of a local drive and a network path. For example, C:\folder\ and \\server\share\folder. The file parameters can contain one or multiple file names and you can make use of ? or * wildcards, the default is *.*, which copies everything. Other switches include the ability to control how copy is handled, timers and retries if interruptions are found, and you can even use a switch to create an output log file. Take a look to the example below:
robocopy "C:\folder" \\server\share\folder\ /MIR /W:15 /R:30 /LOG: \\server\share\logs.txt
The previous command allows you to copy all the content from C:\folder to shared folder in the network, in this case \\server\share\folder\. The /MIR switch indicates that the content has to be mirrored. In other words it will copy all content, folder, subfolders, files and even empty folder from the source and deleting folder in destination if they don’t exit on source. The /W is to set for how long to wait on each retry and /R is to specify the number of retries. In this particular case Robocopy was set to 30 retries at 15-second wait intervals — the default parameters allow 1 million retries at 30-second wait intervals.
To copy only one file, use the following command as an example:
robocopy "C:\folder\" "\\server\share\folder\" file-name-here.iso
You can see how file parameters are secondary, even though the file I want to copy resides on C:\folder the name of the file is not specified until the end of the command — Fully qualified path are not supported.
If you are interested on knowing all Robocopy switches and specifications, open the Command Prompt and type:
Robocopy is really different to what you may have used before, it is a more powerful file management tool that allows you to copy, move and delete files and folders faster than ever before. One thing to keep in mind, is that it takes a little bit of time to learn how to use all the switches, so it is important that you practice with non-essentials data before you start running commands in real content.