Skip to content

Instantly share code, notes, and snippets.

@vyach-vasiliev
Last active March 11, 2023 22:52
Show Gist options
  • Save vyach-vasiliev/67c2c7a6a3a519f33d061e0805a705fa to your computer and use it in GitHub Desktop.
Save vyach-vasiliev/67c2c7a6a3a519f33d061e0805a705fa to your computer and use it in GitHub Desktop.
Fastest copy big files with Robocopy - Windows 10 and above

Fastest copy big files

Robocopy is Robust File Copy, a command-line tool built into Windows 10

How to use multi-threaded feature with Robocopy

  1. Run this Command Prompt with administrator rights.
  2. Run this .bat script in command prompt like:
  • fastcopy "D:\folder" "D:\new_folder"

or for network files

  • fastcopy "\\10.1.2.111\folder" "D:\new_folder"

Robocopy command breakdown

Robocopy has many features, and in the command shown in this guide, we’re using the following switches to make copy reliable and fast.

  • /S — Copy subdirectories, but not empty ones.
  • /E — Copy Subdirectories, including empty ones.
  • /Z — Copy files in restartable mode.
  • /ZB — Uses restartable mode. If access is denied, use backup mode.
  • /R:5 — Retry 5 times (you can specify a different number, the default is 1 million).
  • /W:5 — Wait 5 seconds before retrying (you can specify a different number, the default is 30 seconds).
  • /TBD — Wait for share names To Be Defined (retry error 67).
  • /NP — No Progress – don’t display percentage copied.
  • /V — Produce verbose output, showing skipped files.
  • /MT:32 — Do multi-threaded copies with n threads (default is 8).

The most important switch to focus on in the above command is /MT, which is the switch that enables Robocopy to copy files in multi-threaded mode. If you do not set a number next to the /MT switch, the default number will be 8, which means that Robocopy will try to copy eight files simultaneously. However, Robocopy supports 1 to 128 threads.

In this command, we are using 32, but you can set it to a higher number. The only caveat is that using a higher number will cause higher resource usage and bandwidth. If you have an older processor, using a high number will affect performance. As a result, make sure to test before executing the command with a high number of threads.

You are not limited to copying files and folders to an external or internal drive, and this also works to migrate files over the network.

Sources:

@echo off
robocopy $1 $2 /S /E /Z /ZB /R:5 /W:5 /TBD /NP /V /MT:32
echo copied %1 to %2 completed
@vyach-vasiliev
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment