Robocopy command: Copy only New / Changed files (Sync both the drive)

robocopy command

Robocopy is a command line tool and available free with the download Windows Resource Kit. It is an external command that is available in the below operating systems.

Windows NT , Windows 2000 , Windows Server 2008 , Windows Vista, Windows 7 & Windows XP.

Download Robocopy Command Line Tool for Windows 2003 and 2008 Server / Windows XP / Vista / 7 from following path:

Install the rktool.exeand follow the following steps to copy new and changed files only.

Start > Run > type cmd and press enter to open command prompt window.

Type robocopy /? to get to know about feature provided by Robocopy command line tool. Here i have marked all the feature with grey color and highlighted some feature which i have used to sync my d: drive to destination drive in which the data has to be copied.

C:\>robocopy /?         // Help for any command

Following command i have used to sync my folders and files.

C:\>robocopy "D:\Folder1" "H:\BackupFolder1"  
/E /ZB /X /PURGE /COPYALL /TEE /LOG:E:\Copy_from_HD_to_Ext_HD.log

Meaning of switches used in above command explained below.

/E :: copy subdirectories, including Empty ones.      

/ZB :: use restartable mode; if access denied use Backup mode.

/COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).

/PURGE :: delete dest files/dirs that no longer exist in source.

/X :: report all eXtra files, not just those selected.

/TEE :: output to console window, as well as the log file.

/LOG:file :: output status to LOG file (overwrite existing log).

Above command will sync your data from source to destination it means if you have deleted some data from your hard drive then it will also remove from destination drive. I have made it to sync my data, if you don’t want to delete any files from destination drive then don’t use /PURGE option.

Some More Examples:

robocopy c:\folder1 c:\folder2 *.txt

In this example all .txt files would be copied from folder1 directory to folder2 directory. 

robocopy c:\folder1 c:\folder2 

In this example all files would be copied from folder1 to folder2 but not directories.

robocopy c\:hope c:\hope2 /e

In this example all files and folders (including empty ones) will be copied from folder1 to folder2 directory.

Copy all the files from source and delete all files from source drive but don’t delete folder.

C:>robocopy "E:\source" "E:\destination" /E /ZB /MOV /COPYALL

ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010

Started : Tue May 21 10:17:22 2013

Source : E:source
Dest : E:destination

Files : *.*

Options : *.* /S /E /COPYALL /MOV /ZB /R:1000000 /W:30


3    E:source
100%        New File                1709        Copy from Ext-HD to HD.bat
100%        New File                2711        Copy from HD to Ext-HD.bat
100%        New File                 643        update.bat


Total    Copied   Skipped  Mismatch    FAILED    Extras
Dirs :         1         0         1         0         0         0
Files :         3         3         0         0         0         0
Bytes :     4.9 k     4.9 k         0         0         0         0
Times :   0:00:00   0:00:00                       0:00:00   0:00:00

Speed :               40504 Bytes/sec.
Speed :               2.317 MegaBytes/min.

Ended : Tue May 21 10:17:22 2013


You may also like:

How to install HP LaserJet 1010 driver in Win7

How to get machine serial number, product number using command prompt

160 Run commands for Windows

7 thoughts on “Robocopy command: Copy only New / Changed files (Sync both the drive)”

  1. Anurag Singh

    I have used robocopy and to me a non IT guy it felt like hacking or something. Like they show in movies, typing some commands and then BOOM everything starts to happen. I didn’t felt comfortable using it and at times it started to freeze. My colleagues told me about GS Richcopy 360. It is simple to use and provided me multi threaded file transfer for fast transfer speed, pre scheduled file transfer, email notification when task is done and many more. Try it hope it helps!

  2. Aaditya Singhania

    Obviously RoboCopy is one of the popular software to do the trick. I used it myself for a long time but I felt like it is designed for Linux but patched up to work on Windows which is just a pain to try to get them working, and if they work and break, forget trying to fix them let alone no support. The one program that is similar and allot better than RoboCopy and is best of its kind for windows is GS RichCopy 360 Enterprise. This program works almost the same way except it is DESIGNED for windows and offers a lot more features, it is simple to use and comes with great support. They offer free trial, try it and decide.

  3. wahid haq

    I suggest everyone to try “Long Path Tool” program.
    It’s really work for me.

  4. Ron Cash

    I want to then have “Data Files RC” in “C:\Laptop Backups” zipped with date on end of the file
    so there will be:

    C:\Laptop Backups\
    Data Files RC
    Data Files RC
    Data Files RC
    Data Files RC

    Then I want to look at the earliest date in the “C:\Laptop Backups” directory based on the created date,
    not the date added to the file name, and delete any zipped files older than 14 days. So in the
    example above, I want to get the created date for “Data Files RC” then count back 14 days
    and delete all zipped files older than 14 days.

    I want to use the earliest file date, because if I am on vacation or just not paying attention
    and the system fails, then the delete will not continue deleting files based on todays date.
    If I do not catch this then it would eventually delete all backups.

    So if something fails but the delete is still working it would only delete from 14 days back from
    the point of failure, i.e. so say after 9-26-2014 the copy option is not working, but the
    delete is kicking in, then only 14 days back from 9-25-2014 would be deleted, then also on 9-27-2014 it would
    still only delete from 9-25-2014 14 days back, instead of using 9-27-2014. This then would always have 14 days worth
    of backups from 9-25-2014 back.

    Maybe this is not an issue, but I do have a routine that deletes based on todays date, then I have a separate
    backup software, which I just found was failing, so it occured to me that the delete batch routine that I put in Windows
    scheduler would have eventually deleted all my backups.

    So what is the best way to avoid this, can robocopy be set to look at the earliest file date, then delete older files
    based on that or is there a some other script or combination thereof?

  5. annakram

    Nice post.Another software alternative that works is “LongPathTool” for error messages: Cannot read from source file or disk, there has been a sharing violation, cannot delete file or folder, the file name you specified is not valid or too long, the source or destination file may be in use and many other file managing errors.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top