HomeWindowsBatch file programmingMulti-Threaded Robocopy by First-Level Subfolder

Multi-Threaded Robocopy by First-Level Subfolder

Robocopy is a wonderful tool for synchronizing directories, migrating servers, or just generally copying data on or between Windows systems. The built-in version of Robocopy on Windows 7/Server 2008 R2 introduced a multi-threaded copy option; however, this is not available in earlier editions of Windows. Read on to discover how to do multi-threaded Robocopy operations with a batch file with any version of Windows.

One way to “multi-thread” a Robocopy operation is to spawn multiple instances of robocopy on subfolders of the primary folder which you are copying. Doing this manually is tedious, prone to error, and not particularly efficient.

To use robocopy on any supported version of Windows, you’ll first need to download it and put it in a folder that is in “%PATH%”. Search for the Windows 2003 resource kit, download and install it, then copy robocopy.exe to C:\WINDOWS. Note that this is not necessary on Windows versions that already include it, such as Windows 7 and 2008 R2.

Then download my multi-threaded robocopy batch file: Multi_Robocopy.txt

Change the file extension from .txt to .cmd

Right-click and choose Edit to open it and change the variables as described.

You’ll definitely want to put in an appropriate source and destination directory to replace my temporary placeholders (“c:\temp” and “c:\testdir”).

By default this script will loop through the subdirectories of SOURCE and kick off simultaneous robocopy threads for each processor/core on your machine. You can change the number of threads as indicated from default to any number desired (e.g. THREADS=4 for four simultaneous robocopy operations).

This script is particularly useful for taking advantage of processor and spindle performance when synchronizing directories that contain hundreds or thousands of subdirectories.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!