Tuesday, April 17, 2012

How to copy files using robocopy Windows 7? Is it faster than normal copy or drag and drop?

First of all, I was on search for a utility that can copy a large size of directory into my external drive faster. I found some tools but don't want to install untrusted application into my laptop. I found a "ROBOCOPY" command for Windows 7. I played with it and familiarized myself on how to use it in efficient way. To cut the story short, I want to copy a files and don't print a log information into the console because it will take longer if you're copying or moving a file more than 500,000 files.

The command I used was:

robocopy [SOURCE] [TARGET] /e /copyall /np /fp /ndl /nfl /mt:32

Explanation:

[SOURCE] - Replace it with your source folder or file. This will be the location of your source folder.

[TARGET]- Replace it with target folder or file. This will be the location of your folder or file you want to save.

/E       - Include all empty directory

/COPYALL - Retain all the information like file properties, read-write access, date modified, etc.

/MT:[n] - This option can be range 1 - 128. If you don't specify this option, it will default to 8. This is a Multi-Threading option. This is the one that I like the most. It's like you're hiring 32 worker to do the job. The greater the number the faster the copying process or moving process. In my example above, I used 32 because I'm using other application (i.e. Photoshop CS5, IBM RSA, etc) while doing the copy. If you're not doing anything than copying, you can use 128 and the result is more faster than 32 multi-threaded.

Log Option:

/NP      - Don't display percentage copied

/NDL     - Don't display directory

/NFL     - Don't display file names

/FP      - Include full pathname of files in the output


Example command:

robocopy C:\mysrc L:\backup\mysrc /e /copyall /np /fp /ndl /nfl /mt:32

Output:

-------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------
  Started : Tue Apr 17 09:01:21 2012
   Source : C:\mysrc\
     Dest : L:\backup\mysrc\
    Files : *.*
  Options : *.* /FP /NDL /NFL /S /E /COPYALL /NP /MT:32 /R:1000000 /W:30
-------------------------------------------------------------------
100%
-------------------------------------------------------------------
               Total    Copied   Skipped  Mismatch    FAILED    Extras
    Dirs :       126       125         1         0         0         0
   Files :       753       753         0         0         0         0
   Bytes :  254.38 m  254.38 m         0         0         0         0
   Times :   0:10:36   0:00:19                       0:00:00   0:00:00
   Ended : Tue Apr 17 09:01:41 2012

Note:

You don't need to include /FP option. In my example I purposely included it just to show the difference. The /FP option is useless because I included in a log option to hide any progress information (i.e. /NP /NDL /NFL). Also, make sure that you will run the command prompt as Administrator to avoid some security restriction when copying a file. You can do this by - START - ALL PROGRAMS - ACCESSORIES - then right Click in the Command Prompt and Run As Administrator


Summary:

I will use robocopy from now on to backup my folder/file into an external drive. Based on experience, this is faster than XCOPY in command prompt or Drag and Drop approach in Windows Explorer. I forgot to mention, the SOURCE and TARGET folder can be also a network location. Also, if you want to copy a folder with few files and want to display the percentage of copy just use robocopy C:\myFolderWithFewFiles L:\backup\myFolderWithFewFiles /mt:32 command.