How to Use Robocopy to Copy Multiple Folders to One Location

Learn a full guide to use Robocopy to copy multiple folders to one destination, and get a free tool to copy multiple folders/files using AOMEI Backupper Standard with GUI interface.

By @Jonna Last Updated October 17, 2023

Overview of Robocopy

Robocopy (Robust File Copy) is a potent command-line utility, facilitating swift and efficient data copying, mirroring, or relocation from one location to another. Its versatility shines when backing up data, synchronizing folders, or transferring files across different drives or networks. Robocopy functions as an alternative to Xcopy, with more options. Because it comes with tons of options/switches that you can use to fine-tune and optimize the copy action.

Since the advent of Windows Vista and Windows Server 2008, Robocopy has been an integral Windows standard feature. Its multifunctionality, however, can also pose a common challenge. Given its infrequent use by most people, using which switches or options is a puzzle. For example, how to use Robocopy to copy multiple folders to one location or multiple directories is a headache.

The goal of this post is to give you a quick start guide by providing some Robocopy examples and show you how to use Robocopy to move multiple folders to one destination.

Commonly-Used Robocopy Examples

In the following, you will learn some Robocopy examples. An important limitation to note is that Robocopy cannot copy files that are open or locked, as it does not use VSS (Volume Shadow Copy Service).

Basic syntax for Robocopy

robocopy c:\temp\source c:\temp\destination (This command will copy all files, excluding subfolders, from the designated source (c:\temp\source) to the designated destination (c:\temp\destination) with a bunch of default options.)

Copy all files and folders

robocopy c:\temp\source c:\temp\destination /E /DCOPY:DAT /R:10 /W:3 (With the /E switch, Robocopy is instructed to replicate all subfolders, even those that are empty.)

Robocopy Exclude Folder

robocopy d:\testfiles c:\temp\dst /e /xd "folder a" "folder c" (To exclude specific folders, simply utilize the /xd switch followed by the names of the folders you wish to exclude. In this way, you can use robocopy /xd multiple folders names to exclude folder sync.)

Move examples

/MOV - Moves files exclusively, leaving behind the empty folder structure at the source location.

/MOVE - Moves both files and folders.

Synchronize examples

/PURGE - Remove files and folders from the destination that are no longer in the source, but it excludes subfolders.

/MIR - Mirror the source to the destination, effectively acting as /PURGE /E. Additionally, it copies all files within subfolders, even empty ones.

Filter examples

robocopy d:\testfiles c:\temp\dst *.log (Filtering which files to copy is possible by employing wildcards and filenames. For example, to copy only log files from a specified directory, you can apply a filter based on the .log extension using the wildcard *)

For more information about Robocopy switches and examples, please go to the Microsoft Robocopy page.

How to Use Robocopy to Copy Multiple Folders to One Location

To utilize Robocopy to copy multiple folders, you can follow the steps below. It's essential to understand that this process involves one-way synchronization, and will not change anything from the source folder.

Step 1. Copy and paste the following batch (*.bat) script into your Notepad or other text editor.

@echo off

::Unicode

CHCP 1252

echo %~dp0

::Remove old log file

if exist "%~dp0\robocopylog.txt" del "%~dp0\robocopylog.txt"

::Ignore the following file types. You can add more separated by space

set exclude=*.bak *.backup

::Go through each line in the folders.txt file

for /f "skip=2 delims=" %%f in ('find /v "" %~dp0\folders.txt') do (

::Check if the relative path from current directory works

if exist "%~dp0\%%f" (

::Sync relative path

robocopy "%%f" "%~dp0\%%f" /v /xf %exclude% /mir /tee /fft /log+:robocopylog.txt

) else (

::Sync absolute path if relative didnt work

robocopy "%%f" "%~dp0\%%~nf" /v /xf %exclude% /mir /tee /fft /log+:robocopylog.txt

)

)

::Wait for keyboard input before closing the window. Remove pause if you want it to close

pause

Step 2. Save the script in your desired backup location with a name of your choosing.

Step 3. Create a new text file named folders.txt. Enter the names of the folders you wish to copy, separating each by a line break, as shown in the following picture. Ensure you save this text file in the same directory as the batch script.

Step 4. Execute the script. Upon completion of the process of Robocopy files from multiple folders to one folder, the command window will remain open.

Easier Solution to Copy Multiple Files/Folder

AOMEI Backupper Standard is one of the best free alternatives to Robocopy. It's compatible with all Windows editions, including Windows 11/10/8.1/8/7/Vista/XP. Coming with a GUI interface, it offers various sync features:

  • Basic Sync: it facilitates one-way sync across different locations. For example, you can sync files from one computer to another, sync files to an external hard drive, or sync local folders to cloud services like OneDrive/Google Drive, etc.
  • Auto Sync: Its Schedule Sync function enables you to automate file synchronization at fixed intervals.
  • Background sync: You can copy open or running files with no need to close other running applications.

Now download AOMEI Backupper and follow the instructions below to copy multiple folders automatically:

Download Freeware Win 11/10/8.1/8/7/XP
Secure Download

Step 1. Run the AOMEI Backuppersoftware, navigate to the Sync tab, and select Basic Sync.

More synchronization options are available after upgrading to Pro or higher editions: 💫 Real-time Sync: Synchronize changed files from the source to the destination in real time. 💫Mirror Sync: Maintain the destination directory as an exact mirror of the source directory. 💫Two-Way Sync: Ensure that any changes in either the source or destination directory are synchronized bi-directionally.

Step 2. Click on Add Folder to choose the folder(s) on your computer that need to be synced. You can use the + icon to select folders from different paths.

Step 3. Tap on the second bar to specify the location where you want folders to be copied. It can be a local/external disk, a cloud drive, like Google Drive/OneDrive/Dropbox, or a network path.

Step 4. Tap on Schedule Sync to set up a schedule for your sync task. You have options to choose from daily, weekly, monthly, event triggers, or USB plug in based on your need.

Step 5. Finally, click Start Sync to initiate the sync process.

FAQs about Robocopy Copying Multiple Sources

#1. How Do I Copy Folders and Subfolders in Robocopy?

As mentioned above, the easiest way to copy a folder with all files and subfolders is to run this command: robocopy c:\temp\source c:\temp\destination /E /DCOPY:DAT /R:10 /W:3. The /E switch tells Robocopy to copy all subfolders, including empty ones. If you don't want to copy empty subfolders, use the /S switch.

#2. Is Robocopy faster than Xcopy?

Usually, Robocopy will be the faster alternative in most cases. However, the most significant difference is that Robocopy has a retry option, whereas Xcopy does not retry on errors.

#3. Does Robocopy Copy Hidden Files and Folders?

By default, Robocopy does not copy hidden files and folders. But, the hidden file attribute is copied when you run the Robocopy command together and /NoDCopy option in Windows.

Conclusion

That’s all about how to do multiple folder copy with Robocopy. Yet, you may meet problems using the Robocopy command, or running the command may be difficult for computer green hands to for using Robocopy to sync two or multiple folders. AOMEI Backupper can provide an easier solution in such situations.

Actually, AOMEI Backupper is not only a sync tool but also a backup solution. You can use it to create computer system, disk, partition, and file/folder backups easily. Besides, it provides you with clone functions that can help you clone USB drive to SSD effortlessly.