By Ivy / Last Updated April 27, 2021

Copy only newer files with XCopy or Robocopy, or use easier way:

How do I backup only new or modified files with XCopy?

Xcopy is a command line utility for copying multiple files or entire directory trees from one directory to another and for copying files across a network. Also, you are allowed to copy only new or changed files with it. And it is used in Windows 7/8/10/XP/Vista and Windows Server 2003/2008/2012/2016/2019.

Copying only changed files with XCopy saves much time and disk space, thus many users are willing to only copy updated files. Below is an example from it.

“ I copy my files from Windows 7 to Server 2008 with the following command, but it copies everything.

xcopy C:\source X:\destination /s

I just want to use XCopy command to copy only newer files, because these files are very large. It’s time-consuming.

Is there a way to specifically just copy new or updated files without specifying a date? Any suggestion will be appreciated.‚ÄĚ

Stepwise guide:  XCopy copy only newer files

Before using XCopy to copy only changed files, you need to learn the syntax and some parameters you will use.

Syntax of XCopy command line:  

Xcopy [source] [destination] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d [:MM-DD-YYYY]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a | /m}] [/n] [/o] [/x] [/exclude:FileName1[+[FileName2]][+[FileName3]] [{/y | /-y}] [/z] [/b] [/j]

Options: 

  • /S¬† Copies directories and subdirectories, unless they are empty. If you omit¬†/s,¬†xcopy¬†works within a single directory.
  • /Y¬†Suppresses prompting to confirm that you want to overwrite an existing destination file.
  • /I¬† ¬†If in doubt always assume the destination is a folder. e.g. when the destination does not exist.
  • /E¬† Copy folders and subfolders, including Empty folders.
  • /D:mm-dd-yyyy¬† Copies source files changed on or after the specified date only.¬†If you do not include a¬†MM-DD-YYYY¬†value,¬†xcopy¬†copies all¬†Source¬†files that are newer than existing¬†Destination¬†files.¬†
  • For more options, you can type xcopy /? for all the help or refer¬†to xcopy command in Microsoft.

To copy only updated files with XCopy, you have two options, namely using options /s /d, options /i /d /y. And there are something you need to be aware:

>> This first option will copy files that does not exist in the destination folder if you use /d parameter without specifying a date. To avoid it, you could add the /u  switch. 

>> The second option will ignore the new directories by default. To copy everything, including new directories, you should add the /e switch.

Now, see below and learn the detailed steps. Note that if there are spaces in your directory names, you need to use quotes.

Step 1. Type cmd in the search box and select it.

Step 2. To copy only updated files with XCopy, type the following commands and hit Enter after each one. 

set SourceDir=D:\Source

set TargetDir=K:\Target

xcopy %SourceDir% %TargetDir% /s /d

or 

set SourceDir=D:\Source

set TargetDir=K:\Target

xcopy %SourceDir% %TargetDir% /i /d /y

Note:¬†Please remember to replace ‚ÄúD:\Source‚Ä̬†and ‚ÄĚF:\Target‚Ä̬†with the path of your files.

Xcopy Copy Only Newer Files
Xcopy Command Copy Only Newer Files

Step 3(optional). To copy changed files only exists in the destination path, type the following commands and press Enter in order. 

set SourceDir=D:\Source

set TargetDir=K:\Target

xcopy %SourceDir% %TargetDir% /s /d /u

Step 4(optional). To copy everything including the new directory, type the following commands and press Enter in order. Please remember to replace the following path ‚ÄúD\My Source\stuff‚Ä̬†and ‚ÄĚF:\My Backup\stuff‚ÄĚ.

Set SourceDir=‚ÄĚD:\Source\copy files‚ÄĚ

Set TargetDir=‚ÄĚK:\Target\files copied‚ÄĚ

xcopy %SourceDir% %TargetDir% /i /d /y /e

Copy Everything
Copy Everything

Step 5. Type exit and hit Enter to leave this window.

Robocopy copy only new files step by step 

Robocopy can also help you copy only new files, but it has more options than Xcopy and is considered as a good alternative. Before you use it, please learn the syntax and options you may use. 

Syntax of Robocopy command line: 

robocopy [source] [destination] [[file][ ...]] [options]

Options: 

  • /XO:¬† is used to exclude older files, and usually done with the¬†parameter"/maxage: n".
  • /maxage: n:¬† indicates that the farthest modification time or the specific date, the file whose modification time or date¬†is older than this will not be copied.
  • /XC: Exlude changed files.
  • /XN: Exlude newer files.
  • /XD dirs [dirs]:¬† Exlude directories mathcing given names and paths.
  • /S:¬†Copy subdirectories, excluding empty ones
  • /Z:¬†Restartable mode
  • /fft:¬†Make the modify time comparison more tolerant(2 seconds granularity)
  • /Mir:¬†Mirror¬†a directory tree
  • For more options, you can type¬†robocopy /? for all the help or refers to Robocopy command in Microsoft.

To copy only changed files with Robocopy, you have two options, namely using option maxage: n or option /XO /maxage: n. But some users say that they don't want to create all the subfolders on the target disk if there is no new files in them. In this case, you need to add extra switch /S to exclude the empty folder.

Then, let's go through the following steps to copy only new files:

Step 1. Open the command prompt with administrator priority.

Step 2. Type the following commands and hit Enter in order.

robocopy D:\folder1  E:\folder2  / maxage:7

or 

robocopy D:\folder1  E:\folder2  /XO /maxage:7

Robocopy Copy Only New Files
Robocopy Copy Only New Files

Step 3. To copy new files while excluding empty folder, type the following command and hit Enter in order.

robocopy D:\folder1  E:\folder2  /s /maxage:7

or 

robocopy D:\folder1  E:\folder2  /XO /s /maxage:7

Easier way to copy only new or modified files

As for you can see from above, whether using XCopy or Robocopy, you need to learn the syntax and some parameters, and none of them is easy for home users. Well then, is there any way to copy only changed or new files?

The answer is Yes, you could use a professional file backup software like AOMEI Backupper Professional. It allows you to backup only changed files in Windows 7/8/8.1/10/XP/Vista with the help of daily/weekly/monthly schedule backup together with incremental or differential backup. To copy files from server to server, you could use AOMEI Backupper Server.

They are based on full backup, but not exactly the same. For differences, you can see from the comparison chart below.

  Full Backup Differential Backup Incremental Backup
Backup Speed Slowest Moderate Fastest
Storage Space Most Moderate Least
Restoration Speed Fastest Moderate Slowest

In addition, this software offers users more advanced features.

  • Normal or High compression level: It is able to compress image file with a smaller one, thereby saving disk space. Note the high compression level requires more backup time.
  • Backup Scheme: It allows you to delete old backup image with¬†a specific role so as to free up disk space.
  • USB plug in: To backup your files flexibly and take it everywhere, you can create a schedule backup with "USB plug in" feature. It does not require any human interference.¬†¬†
  • Wake the computer to run scheduled tasks:¬† It is capable of waking computer 2 minutes before the scheduled task starts. It's very convenient when you need to¬†backup files during¬†off-peak hours.

Then, see below and learn the specific steps.

Step 1. Download AOMEI Backupper Professional, install and launch it. Then, prepare an external hard drive or other storage as backup destination and connect it to your computer.

Download Free Trial Win 10/8.1/8/7/XP
Secure Download

Step 2. Click Backup and File Backup subsequently.

File Backup
File Backup

Step 3. Click Add File or Add Folder to select the files or folders you want to backup and then click OK. Then, select the prepared storage device to store your image.

Add File or Folder
Add File or Folder

Step 4(Required). Click Schedule, select daily/weekly/monthly backup and then incremental or differential backup. 

Schedule Settings General
Schedule Settings General

Step 5. After that, confirm all the selected settings and click Start Backup. It will backup your files immediately and then backup only changed files at the next time.

Bonus tip

Reading here, you may know how to copy only newer files with XCopy or its alternative Robocopy. To be honest, both of them are not suitable for common users. They rarely touch the command line.

Thus, it's wise to copy the changed file with AOMEI Backupper. With a clear interface and user-friendly design, it makes all the steps become easier. And it has more useful features, such as, daily incremental backup, system backup, disk backup, system clone, disk clone, mirror sync, etc.

Believe me, it's one of the most powerful software to protect your data by its complete solution. Please download it to have a try right now!