Sync Two Folders with Robocopy Command Line in Windows

You will learn more about Robocopy and examples to perform Windows sync two folders via command line - Robocopy. Meanwhile, this article offers an easier way.


by Ivy Updated on March 27, 2024

Share this: instagram reddit

User Case: How Do I Sync Two Folders with Robocopy?

"Hi, we have two shared folders. One is primary which is shared with the user and almost about to fill and the other is not shared yet but I want to sync all the data from primary to new one with Robocopy command line.

The problem is how do I sync two folders with Robocopy? I don't want to sync current files already in the new folder, only changes in the primary folder to new folder. Thanks."

Windows Sync Two Folders with Robocopy Command Line

Sometimes, you may need to  sync two folders located in different computers or other locations, such as, internal or external drives, to make the two folders keep the same content. Here we will show you different ways to perform Windows sync two folders with command line tool.

🌟Quick Navigation:

Robocopy one-way sync two folders More...>>

An easier way to sync two folders in Windows-AOMEI Backupper More...>>

Robocopy Command Line Syntax and Options

Robocopy is a robust file copy command for Windows PCs and it allows you to copy files, directories, and even drives from one location to another. It provides you with different parameters to sync two folders in Windows 11/10/8/7.

👉 Robocopy command line syntax: You can specify the path to source and destination directory, files or folders you want to sync and other options. 

robocopy [Source] [Destination] [(File)( ...)] [(Options)]

Source It specifies path to source directory, type as, drive:\path or \\server\share\path.
Destination It specifies path to destination directory,  type as, drive:\path or \\server\share\path.
File It specifies files you want to copy, type as, names/wildcards: default is "*.*".
Options It specifies copy, file, retrt, logging, and job options to use with robocopy command.

👉 Common used options in Robocopy: 

  • /s: Copies subdirectories. Note that this option excludes empty directories.

  • /e: Copies subdirectories. Note that this option includes empty directories.

  • /lev: Copies only the top N levels of the source directory tree.

  • /z: Copies files in restartable mode.

  • /b: Copies files in Backup mode.

  • /zb: Uses restartable mode. If access is denied, this option uses Backup mode.

  • /efsraw: Copies all encrypted files in EFS RAW mode.

  • /copyall: Copies all file information, including D (Data), A (Attributes), T (Time stamps), S (Security: NTFS access control list (ACL)), O (Owner information), U (Auditing information)

👉 To know more parameters you could use, please input robocopy /? to get more details.

Robocopy Commands

How to Perform Robocopy One-Way Sync Two Folders 

In general, Robocopy is a one way file sync solution, and you can sync files easily from one location to another  as long as you use the right options. And I will introduce you to the most common cases below. Note that you need to run cmd as administrator in all the following situations. 

Situation 1: Robocopy Sync Two Shared Folders 

The first case is to sync two folders on different computer through shared folder. For example, to sync tmp folder(and its subfolders) located in \\\PublicShare\ to \\\WorkD, please input the following command line:

robocopy \\\PublicShare\temp \\\WorkD /e /copy:DAT /mt /z

Robocopy Sync Two Folders 


  • /copy:DAT: means you will copy the source folder to destination folder with D (Data), A (Attributes), T (Time stamps), and you could modify these copied files. If you don’t want to modify these folders and files, you could replace /copy:DAT to /copyall or /copy:DATSOU.

  • /mt: Creates multi-threaded copies with 8 threads.

Situation 2: Robocopy Incremental Sync

Except for simply sync two shared folers, you still can create incremental sync task with Robocopy command line. You will use the /xo or /xc option, which has the ability to let Robocopy sync changes only to the destination folder.

For example, to sync changed part from source \\\PublicShare\temp to \\\WorkD in restart mode and creates multi-threaded copies with 8 threads, input the following command line:

robocopy \\\PublicShare\temp \\\WorkD /e /copy:DAT /mt /z /xc /xn /xo

Robocopy Incremental Sync


  • /xo: Excludes older files (excludes existing files older than the copy in the source directory). 

  • /xc: Excludes changed files (excludes existing files with the same timestamp, but different file sizes).

  • /xn: Excludes newer files (excludes existing files newer than the copy in the source directory).

  • /mt: Enable multithreaded copying and the default threads is 8. If you don't want to use the default, you can specify it yourself. 

  • With /xc, /xn, /xo specified, Robocopy will exclude files existing in the destination directory.

Situation 3: Robocopy Real Time Sync Two Folders

Besides, Robocopy still offers you /mot:  to monitor changes in M minutes (only accept minutes as argument). Note the changes less than one minutes will not be included.

For example, monitor every one minutes based on the above command, type the following command:

robocopy \\\PublicShare\temp \\\WorkD /e /copy:DAT /mt /z /xc /xn /xo /mot:1

Robocopy Real Time Sync Two Folders


  • /mot:: Monitors the changes in source every N minutes and sync it to destination.

Other Robocopy Sync Situations

Except for the above cases, you still can use batch files and  Windows Task Scheduler to continuously copy all file changes.

Besides, you could specify the mirror sync task with the /purge parameter, it will delete destination files and directories that no longer exist in the source. 

For two-way sync, you need to create a batch file with Notepad. For detailed steps, please refer to Robocopy two-way sync

Windows Sync Two Folders Command Line Limitation

Robocopy is good assistant to helps you perform one way, but there are some restrictions using Robocopy sync two folders:

  • Robocopy parameters are quite complicated for computer novices to understand.

  • Robocopy does not copy open files. 

  • Robocopy does not mirror files properly in system older than Windows Vista. 

  • Robocopy will disable reporting of the progress percentage for files that are ignored if you use /mt option. 
  • You will lose important files and folders once specified the wrong parameters.

Easier Way to Sync Two Folders in Windows 

Except for the Robocopy command line, you still can try GUI-based file synchronization software - AOMEI Backupper Professional. It supports Windows XP, Vista, 7, 8, 8.1,10 and 11(32-bit and 64-bit) and helps you sync two folders easily with the following options.

AOMEI Backupper
Easy File Syncing Software
  • Basic Sync: It will sync files from one location to another and supports daily, weekly, monthly, event trigger and USB plug in schedule sync settings.
  • Real-Time Sync: It will monitor and sync changes immediately once it's detected, thus maximizing the retention of changes.
  • Mirror Sync: It is a one-way file sync method and more concerned about files in the destination, any change will be undo, and you cannot add new files to it, or delete files already in it.
  • Two-Way Sync: Unlike the previous 3 methods, it will sync files between source and destination directory. All the schedule sync settings are supported.

Besides, it still allows you to sync two folders to multiple destinations, such as local disk, external hard drive (HDD or SSD), CD/DVD, USB flash drive, network share or NAS, even to cloud drives like Google Drive, Dropbox, OneDrive, Box, etc.

To get started, please download AOMEI Backupper Professional and install it on a Windows PC. For server users, try AOMEI Backupper Server!

Step 1. launch AOMEI Backupper Professional on your Windows 10 computer, select Sync tab and then a method to sync two folders, here take Real-Time Sync as an example.

Real Time Folder Sync

Step 2. Press + Add Folder button and then Share/NAS.

Add Shared Folder

Step 3. Click Add Share or NAS Devices and then input the display name and network path to add the network share, and choose the folders you want to sync. You still need to type username and password if you receive error while adding network path. 

Add Network Path

Step 4. Click the triangle icon and tap Add Share or NAS Devices, type network path in the pop-up window and select another folder as destination.  

Add Share or NAS Devices

Step 5. Hit Start Sync >> to sync two folders in real time in Windows. Optionally, you can click Options to comment the real time folder sync task, email or SMS notification, and verify the integrity of the files in the destination location during synchronization, etc.

Start Sync Shared Folder To Another Shared Folder

After the first full folder sync, then any changes made on the source folder will be synced to the destination immediately. It's the safest way to protect files, and meanwhile, it will take up the most disk space compared to other sync methods. 

Of course, if you mind the disk space issue, you can also use other sync methods (eg: Mirror Sync) to sync files with daily, weekly, or monthly frequency, or based on event triggers, USB plug in. This can alleviate the disk space problem to some extent. 

Sync Automatically

To completely resolve this issue, you could consider using the Backup feature to duplicate files. It not only schedules backup files but also deletes old backup images automatically to free up disk space. You have 3 options in following:

  • By quantity: The default number of backup set is 1 and the old backups in it will be deleted after exceeding. 
  • By time: The default set time is 7 days, you can set more or use week(s) or month(s) as basis. 
  • By daily/weekly/monthly: This method is the safest, which keep all the backups within several days, and then only full backups in weeks, finally only one full every month . 


Besides, you still can choose to backup folders to AOMEI Cloud, a cloud drive with 1TB of free storage, and you have 15 days of free access to it after registration. And it enables you to run this task automatically, such as, daily, weekly, or monthly. 

Signup and Login


FAQ on Windows Sync Two Folders Command Line

1. Can I schedule folder synchronization tasks using the Windows Task Scheduler and command-line tools?

Yes, you can schedule folder synchronization tasks using the Windows Task Scheduler in conjunction with the `robocopy` command-line tool. Simply create a new scheduled task, specify the `robocopy` command with the desired options and switches, and set the schedule for when you want the synchronization to occur.

2. Are there any precautions I should take before syncing folders using the command line?

Yes, it's essential to review and understand the `robocopy` options and switches you're using to ensure that the synchronization operation behaves as expected. Additionally, always double-check the source and destination paths to avoid accidental data loss or overwriting important files.

3. Are there alternative command-line tools or methods for syncing folders in Windows?

 While `robocopy` is a powerful and commonly used command-line tool for folder synchronization in Windows, there are alternative tools available, such as `xcopy` and `rsync` (which can be used on Windows via third-party implementations). However, `robocopy` is often preferred for its robustness, flexibility, and built-in support in Windows environments.

4. How do I sync folders in batch file?

You can sync folders using a batch file by leveraging command-line tools such as robocopy or xcopy. Below is an example of how you can create a simple batch file to sync two folders using robocopy:

@echo off set source_folder=C:\path\to\source set destination_folder=D:\path\to\destination

robocopy "%source_folder%" "%destination_folder%" /mir

The Epilogue

Compared with Windows sync two folders via command line tool - Robocopy, the best file sync software - AOMEI Backupper Professional provides you flexible ways to sync two folders in Windows 11, 10, 8, and 7. You can choose different sync methods and schedule settings based on your needs.

In addition, it still a professional backup software. If you don't want the files occupying much disk space, try the File Backup feature. And then, you can enable schedule backup, incremental or differential backup and automatic backup cleanup to manage backup task and disk space flexibly.

Ivy · Editor
Ivy is an editor of AOMEI Technology, she covers backup & restore,hard disk & partitions management and cloud files transfer and so on for AOMEI. She is an outgoing girl and enjoys helping people find solutions to their problems. She loves traveling, eating, reading and so on. She usually hangs out with friends at her leisure time.