Copy or Backup Files Faster in Windows 7 or Vista Using Window's Robocopy

(1 vote, average 5.00 out of 5)

In all versions of Windows 7 there is a little known but easy to use utility bundled in called Robocopy.  Why would you want to use Robocopy over just dragging and dropping or copying and pasting files and folders over manually? Here are some reasons why you might want to add Robocopy to your toolbox of useful utilities:

  1. Robocopy is MUCH faster at copying a large number of files from one location to another compared to the built in Windows copy.
  2. Robocopy can intelligently "Backup" (Mirror) a large number of files.
  3. Robocopy can delete a large number of files efficiently as well.

About COPYING:

Why is Robocopy much faster at copying files than the built in Windows copy?  Robocopy supports what is called Multi-Threading. In other words, think of Robocopy as a team of workers moving rocks from one pile to another where as Windows is a single worker moving rocks.  When Windows copies or moves files over, it performs this task one file at a time.  If there is a large file that Windows is moving over, it will spend ALL of its TIME moving just that ONE file despite the fact that there might be 100 smaller files that could be moved quickly.  What Robocopy does is attempt to copy or move 8 files (By default) at the same, so if 1 file is taking a long time, 7 other files can be copied and moved independently.  This results in a significant decrease in the time it takes to copy or move a large number of files when using Robocopy.

About BACKING UP (MIrroring):

Robocopy can also be used to perform simple one to one backups of files; subsequent backups to the same location will be MUCH faster.  Robocopy can be easily configured to check which files and folders exist in the destination (copy to) location that exist (or don't exist anymore) from the source (copy from) location.  Robocopy will skip copying these files if they already exist, add files if they don't exist, and delete files from the destination (copy to) location resulting in FAST simple backups! Awesome! 

About DELETING:

As with copying, Robocopy can be used to delete a large number of files quickly and efficiently too.  Although Robocopy isn't designed to do this, there is a simple trick that can be used to do this as well.  Same principle applies - Multi-Threaded which allows Robocopy to delete multiple files at a time instead of one at a time.

using robocopy to copy, backup, delete files:

So now that you know some basics about Robocopy, lets examine some useful commands and SEE HOW we can use this!

  1. Open the Command Prompt. This can be done by opening up the Start Menu and typing 'cmd' into the "Search Programs and Files" text box.  It will be called "cmd.exe" with a black icon.     
  2. StartRun

  3. You'll get a black windows with C:\WINDOWS\system32\cmd.exe written across the top bar.  Now you're ready to start using Robocopy!
  4. BlankCommand

 

 

 

 

 

 

 

 

 

 

 

 

 

Copying all files and folders from one location to another location:

Type:  "robocopy {source location} {destination location} /E"  

Example:  robocopy C:\exampleSourceFolder1\exampleSourceFolder2  D:\exampleDestinationFolder1 /E

Note:  This will copy "exampleSourceFolder2" including all files and folders inside to "exampleDestionationFolde1".  The "/E" on the end tells Robocopy to copy everything.

 

Backing up all files and folders from one location to another location (Making an exact copy of the source location at the destination location):

Type: "robocopy {source location} {destination location} /E /MIR"

Example:  robocopy C:\exampleSourceFolder1\exampleSourceFolder2  D:\exampleBackupDestinationFolder1 /E /MIR

Note: This will copy "exampleSourceFolder2" including all files and folders inside to "exampleBackupDestinationFolder1".  Files that exist in exampleSourceFolder2 that DO NOT EXIST at the same location inside exampleBackupDestinationFolder1, will be created at the destination location.  Files that EXIST in the destination location that DO NOT EXIST in the source location WILL BE DELETED!  Files that EXIST in exampleSourceFolder2 that EXIST in exampleBackupDestinationFolder1 THAT ARE EXACTLY THE SAME will be SKIPPED (Much faster on subsequent backups to the same location!).  Files that EXIST and are NEWER in the sourceFolder2 than the files that EXIST and are OLDER in the exampleBackupDestionationFolder1 location will be REPLACED! Robocopy will make an exact copy (Clone) of the source folder to the destination folder. So be careful that you're not replacing or deleting files in your backup location that aren't in your source location.  As a simple backup that creates a clone, Robocopy is fast and easy to use.

Deleting a large number of files and folders quickly:

Create an empty folder; for example, C:\MyNewEmptyFolder

Type: "robocopy {empty folder location} {location folder to delete} /E /MIR"

Example: robocopy C:\MyNewEmptyFolder C:\folder1\folder1\MyFolderWIthThousandsOfFiles /E / MIR

Note: Because Robocopy will make the destination folder an exact copy of the source folder, if the source folder is empty, Robocopy will empty the destination folder (including all files and folders inside).

 

There are lots of ways to tweak Robocopy to do things like copying only a specific file type or to ignore files that are in use or locked.  Here are some additional "flags" that you can put at the end of your Robocopy command:

Control the number of retries:  /R:n   Where 'n' is a number (e.g. 1 or 27) of times to retry to copy a file

 Control the length of time to wait before retrying again: /W:n   Where 'n' is a number (1 or 300) representing the number of seconds to wait before retrying.

 Stop Robocopy from getting stuck in a loop:  /XJ

Control the number of "workers" or Threads that Robocopy will try to use:   /MT:n   Where 'n' is a number between 1 and  128

For a list of additional commands, type into the Command Prompt:   robocopy /?   

Partner Links:
Last Updated on Tuesday, 07 February 2012 20:21  
Related Articles

» How to Move the Task Bar in Windows XP/Vista/7

Although having the task bar (the bar in Windows which usually sits at the bottom of your screen, with the Start button in the lower left) at the bottom screen is very typical, some people like to have it on the side or even on the top.  Or you may have just moved your task bar on accident and now don't know how to get it back.  Here's how to move it.Right click on the task bar and verify that the "Lock the Taskbar" option is unchecked.  If this is checked, the task bar is locked...

» Make an ISO file from Folders or CDROM drive in Linux

If you want to create an ISO image of a CD/DVD or a folder and its contents for archive purposes, copies, easy mounting, burning out, and other purposes, Linux comes with two quick and easy to use command line utilities to make this happen dd and mkisofs.First you will need to open a terminal ("CTRL + ALT + T" in Ubuntu) and type in the following commands for the operation you want to accomplish. CD/DVD Drive:Type: sudo umount /dev/cdrom to unmount your CDRom drive from the...

» Java - Reading and writing a properties file

A properties file in Java can be very useful when you start to notice that there are many locations in your code where you are either hard coding values, many constants, or using enums. Instead of including these values directly in your code, you can refactor them out to a properties file to separate responsibilities. Instead of potentially specifying values throughout many classes or programs, all values can be condensed into one or more properties files as need.An example of a properties file...