Robocopy Syntax, Command Line Switches and Examples

»»»Robocopy Syntax, Command Line Switches and Examples
Robocopy (Robust File Copy) is a command-line file copying tool included in Windows operating system beginning from Windows Vista, and available in every new versions of Windows since, including Windows 7, Windows 8, Windows 8.1, Windows 10 and their server variants. Although Robocopy is available for free with the download Windows Resource Kit since Windows NT 4.0, it has never been an official feature of the operating system until the arrival of Windows Vista.

Unlike other built-in file copying commands such as Copy and XCopy, Robocopy is designed for reliable copy or mirroring of entire folders of any size, and in the copying process, ensure that all NTFS ACLS, attributes, owner information, alternate data streams, auditing information, timestamps and properties are copied except security information unless explicitly requested with /COPYALL switch. And best of all, Robocopy works over network connections that are subject to disruption or outages with resume copying feature, and has progress indicator on the command line that is useful when copying large files.

Robocopy Syntax

ROBOCOPY source destination [file [file]…] [options]

where source is Source Directory (drive:\path or \\server\share\path), destination is Destination Directory (drive:\path or \\server\share\path) and file is File(s) to copy where names or wildcards can be specified and default is “*.*” (all files).

Robocopy Options and Switches

Copy options :

/S :: copy Subdirectories, but not empty ones.
/E :: copy subdirectories, including Empty ones.
/LEV:n :: only copy the top n LEVels of the source directory tree.

/Z :: copy files in restartable mode.
/B :: copy files in Backup mode.
/ZB :: use restartable mode; if access denied use Backup mode.
/EFSRAW :: copy all encrypted files in EFS RAW mode.

/COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
(copyflags : D=Data, A=Attributes, T=Timestamps).
(S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

/DCOPY:T :: COPY Directory Timestamps.

/SEC :: copy files with SECurity (equivalent to /COPY:DATS).
/COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
/NOCOPY :: COPY NO file info (useful with /PURGE).

/SECFIX :: FIX file SECurity on all files, even skipped files.
/TIMFIX :: FIX file TIMes on all files, even skipped files.

/PURGE :: delete dest files/dirs that no longer exist in source.
/MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).

/MOV :: MOVe files (delete from source after copying).
/MOVE :: MOVE files AND dirs (delete from source after copying).

/A+:[RASHCNET] :: add the given Attributes to copied files.
/A-:[RASHCNET] :: remove the given Attributes from copied files.

/CREATE :: CREATE directory tree and zero-length files only.
/FAT :: create destination files using 8.3 FAT file names only.
/256 :: turn off very long path (> 256 characters) support.

/MON:n :: MONitor source; run again when more than n changes seen.
/MOT:m :: MOnitor source; run again in m minutes Time, if changed.

/RH:hhmm-hhmm :: Run Hours – times when new copies may be started.
/PF :: check run hours on a Per File (not per pass) basis.

/IPG:n :: Inter-Packet Gap (ms), to free bandwidth on slow lines.

File Selection Options :

/A :: copy only files with the Archive attribute set.
/M :: copy only files with the Archive attribute and reset it.
/IA:[RASHCNETO] :: Include only files with any of the given Attributes set.
/XA:[RASHCNETO] :: eXclude files with any of the given Attributes set.

/XF file [file]… :: eXclude Files matching given names/paths/wildcards.
/XD dirs [dirs]… :: eXclude Directories matching given names/paths.

/XC :: eXclude Changed files.
/XN :: eXclude Newer files.
/XO :: eXclude Older files.
/XX :: eXclude eXtra files and directories.
/XL :: eXclude Lonely files and directories.
/IS :: Include Same files.
/IT :: Include Tweaked files.

/MAX:n :: MAXimum file size – exclude files bigger than n bytes.
/MIN:n :: MINimum file size – exclude files smaller than n bytes.

/MAXAGE:n :: MAXimum file AGE – exclude files older than n days/date.
/MINAGE:n :: MINimum file AGE – exclude files newer than n days/date.
/MAXLAD:n :: MAXimum Last Access Date – exclude files unused since n.
/MINLAD:n :: MINimum Last Access Date – exclude files used since n.
(If n < 1900 then n = n days, else n = YYYYMMDD date)./XJ :: eXclude Junction points. (normally included by default)./FFT :: assume FAT File Times (2-second granularity). /DST :: compensate for one-hour DST time differences./XJD :: eXclude Junction points for Directories. /XJF :: eXclude Junction points for Files.Retry Options :

/R:n :: number of Retries on failed copies: default 1 million.
/W:n :: Wait time between retries: default is 30 seconds.

/REG :: Save /R:n and /W:n in the Registry as default settings.

/TBD :: wait for sharenames To Be Defined (retry error 67).

Logging Options :

/L :: List only – don’t copy, timestamp or delete any files.
/X :: report all eXtra files, not just those selected.
/V :: produce Verbose output, showing skipped files.
/TS :: include source file Time Stamps in the output.
/FP :: include Full Pathname of files in the output.
/BYTES :: Print sizes as bytes.

/NS :: No Size – don’t log file sizes.
/NC :: No Class – don’t log file classes.
/NFL :: No File List – don’t log file names.
/NDL :: No Directory List – don’t log directory names.

/NP :: No Progress – don’t display % copied.
/ETA :: show Estimated Time of Arrival of copied files.

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

/UNILOG:file :: output status to LOG file as UNICODE (overwrite existing log).
/UNILOG+:file :: output status to LOG file as UNICODE (append to existing log).

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

/NJH :: No Job Header.
/NJS :: No Job Summary.

/UNICODE :: output status as UNICODE.

Job Options :

/JOB:jobname :: take parameters from the named JOB file.
/SAVE:jobname :: SAVE parameters to the named job file
/QUIT :: QUIT after processing command line (to view parameters).

/NOSD :: NO Source Directory is specified.
/NODD :: NO Destination Directory is specified.
/IF :: Include the following Files.

Robocopy Examples

To use Robocopy is simple, just like how you would use Copy and Xcopy commands. For example, to copy entire folder of C:\Users to C:\UserBackup, simply type:

Robocopy C:\Users C:\UserBackup

By | 2016-12-09T08:40:05+00:00 December 9th, 2016|Categories: Utilities|Tags: , |33 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.
  • kicker

    Note that the XF switch does not accept folderwildcard. This is MAJOR deficiency.

    ERROR : Invalid Parameter #4 : "C:dir*.doc"
    ERROR : Invalid Parameter #4 : "dir*.doc"
    ERROR : Invalid Parameter #4 : "dir*.doc"


  • Pingback: links for 2008-09-28 |

  • king joz

    robocopy is a solid and efficient program. it helped me a lot.

  • Dave Mitchell

    I am using the following command line to move files that have not been accessed in more than two years. Problem is, ROBOCOPY seems to ignore the /MINLAD:730 switch, I even tried using /MINLAD:20071028 siwtch to no avail. All the files are moved:

    WHat am I doing wrong?

  • Alex

    Did you ever get the correct syntax?

  • Joshi

    I am using BeyondComapre to copy the files from one system to other. We are using following command (here we are filtering something)
    load "SystemNameLogfiles" "SystemNameLoglocationdcs00onxohs7n66zpqh7ksvx0_3m8h"
    filter "*_3m8h-dcs-*.*;-W3SVC1"
    sync update:lt->rt

    I want to perform same task( copy and filering) using robocopy. Can anyone guide mme on this?

  • To Dave Mitchell

    Only possible explanation is the number is too large for your situation meaning ALL files have a more recent access time. Not sure if last modified (/MINAGE:730) is what you should try.

  • Pingback: Using Robocopy and Volume Snapshots to replicate data |

  • Rob Leenheer

    IF you want to actually USE those exit codes usefully, try RoboCopyPlus (
    It sends email notifications on warnings and errors, condenses and attaches log files.
    An awesome flexible little utility wrapping around yoru already installed MS ROBOCOPY, soit works with all versions.

  • FYI….

    This is how we do our backups at all of our client sites and it works.

    Create your folders

    = Defrag batch I.E. defragc.bat

    defrag c: -f
    cd c:atchlogs

    = Create monday.bat tuesady.bat """""

    net stop "papercut print logger"
    SET _source="C:Program FilesPaperCut Print Loggerlogs"
    SET _dest="E:Papercutoriginal_Logs"
    SET _what=/E
    :: /COPYALL :: COPY ALL file info
    :: /B :: copy files in Backup mode.
    :: /SEC :: copy files with SECurity
    :: /MIR :: MIRror a directory tree
    SET _options=/R:0 /W:0 /LOG:c:atchlogspapercutlogs.txt /NFL /NDL
    :: /R:n :: number of Retries
    :: /W:n :: Wait time between retries
    :: /LOG :: Output log file
    :: /NFL :: No file logging
    :: /NDL :: No dir logging
    ROBOCOPY %_source% %_dest% %_what% %_options%
    SET _source="C:Program FilesPaperCut Print Loggerlogscsvdaily"
    SET _dest="E:PapercutMerge_DataWorking"
    SET _what=/E
    :: /COPYALL :: COPY ALL file info
    :: /B :: copy files in Backup mode.
    :: /SEC :: copy files with SECurity
    :: /MIR :: MIRror a directory tree
    SET _options=/R:0 /W:0 /LOG+:c:atchlogspapercutlogs.txt /NFL /NDL
    :: /R:n :: number of Retries
    :: /W:n :: Wait time between retries
    :: /LOG :: Output log file
    :: /NFL :: No file logging
    :: /NDL :: No dir logging
    ROBOCOPY %_source% %_dest% %_what% %_options%
    net start "papercut print logger"
    cd c:atchlogs

    = Place blat and you emaildefragcconfirm.bat for the defrag.bat
    = Create emailprintlogs.bat for the backup batch

    cd c:atchlogs
    blat -to
    -subject "ClientSite – Username Weekly Defrag c: drive"
    -body "Your Defrag Batch – Clientsite – username C: Drive has been processed and is now completed. No further action is required."
    -port 25
    -ppw XXXX

    cd c:atchlogs
    blat papercutlogs.txt
    -subject "XXXX Weekly printlogs copy and merge"
    -port 25
    -ppw XXXX

    I hope it helps 🙂

  • To use the batch files below we create "Scheduled Tasks" and set the Domain Administrator "domainAdministrator" as the user.

    Monday_backup.bat run Monday at 2am
    Tuesday_backup.bat run Tuesday at 2am
    upto Friday1 through Friday5 and if you have space you can even do a monthly

    The file structure on the backup drive looks like this:

    Z:BackupTuesday ….
    Z:BackupFriday2 ….
    Z:BackupSystemState (if you want to have fun)

    It can be a local drive or mapped drive


    cd z:
    mkdir -p "/serverbackup/friday4/system_state" REM creates the dir if not already setup
    ntbackup backup systemstate /J "Backup Job 1" /F "Z:ackupfriday1system_stateSS_backup.bkf"
    REM invokes windows backup to create system state
    cd c:atchlogs
    REM sends the log file

    We set the defrag batch to run three days a week

    After all of these run it will email us so we can log into that mail account and review our logs.

  • Robert J. Zamora

    Maybe I'm missing the obvious, but, is there a way to use RoboCopy so that it only copies new and changed files?
    Thanks in advance, RJZ

  • Pingback: Moving thousands of files - IT Certification Forums()

  • Geoff

    I cannot accept that robocopy is simple. Prevously if I wanted to copy a file it was just filepath/name and destination path;

    c:mydatamydata.dat d:mydata

    Try this is robocopy and you just get errors.

    • chucktattoo


      You just don't understand how to use it. It is a fantastic tool. You can't use the command:
      robocopy c:mydatamydata.dat d:mydata

      the proper syntax is:
      c:mydata d:mydata mydata.dat

  • Moop Meeper

    ROBOCOPY don't work on VISTA
    switches all seem to be f***ed up, typical M$ catastrophe.

    Now using another FREE proprietary based program to make my daily, weekly and monthly backup's of my very important files.

    M$ extol the virtues of telling everyone to make backup's, but don't provide the correct and working tools to do the job..

    Moop Meeper

  • unokawal

    how do i copy from one folder to another without changing the permissions on the destination folder??

  • Don

    It is interesting to read people's different views on Robocopy. I was always struggling with it when copying file to my media player, over WiFi.

    If anyone is interested, I developed a small utility I am prepared to share. Without making this sound too much like an advert, it is called RoboMate and it is a simple interface "front end' for Robocopy.exe. It may not do everything you require, but you are welcome to have a go with it. It's also FREEWARE.

    Download it from:

    I hope it can help someone.

    • Patrick McKeeby

      Don, many thanks for the file – I’m using it.

    • worldunix

      Where is the download link this one is broken…
      Thanks everyone

  • ririmia

    This is how we use robocopy for archiving files not accessed for 365 days.



    :: RoboCopy Settings
    SET SOURCE="D:DFSstore1Common_%SUC%"
    SET DESTINATION="F:Arhiva_Common"

    SET LOG_FNAME="F:Backup_Archive_%SUC%.txt "


    SET EXCLUDE_DIRS=/XD "DfsrPrivate"

    SET EXCLUDE_FILES=/MINLAD:365 /XF "Common Security.xls"

    SET OPTIONS=/R:1 /W:1 /LOG:%log_fname% /E /XJ /NDL /NP

    :: Start backup

  • Per Haastrup

    I have used Robocopy to backup my workdir. Now today, I needed backup files, and find out, that NO files vere backup 🙁
    What have I done wrong ?? The files exist, but they was from first time i make the backup.
    I used it in a simple batchjob, and I need to backup only files which is changed, can someone help me with correct attributes – help.
    My batch file look lige this.


    ROBOCOPY c:faelles z:backupfaelles /dcopy:T /S /xn

    ROBOCOPY z:backupfaelles d:backupfaelles /dcopy:T /S /xn


    First I copy to my networkharddisk Z: after that I copy to my harddisk D on my PC.

    Per Haastrup

  • Maddy

    I am trying to copy files from my local machine to server using ROBOCOPY. It is ending with the error message. “Accessing the destination directory. Network path was not found.”

    Source D:\TestFile
    Destination \\ServerName\D:\TestFile

    DO I need to mention any login details get the access in batch file.

    I run the following command using BATCH file.

    robocopy /s /e /v /c “D:\TestFile” “\\ServeraName\D:\TestFile”

    Please reply.

    • Pierre Labrie

      The syntax for an unc adress is

      robocopy /s /e /v /c “D:\TestFile” “\\ServeraName\D$\TestFile” If you have D$ as a share or use the name of a share with write permission for the user of Robocopy. I you use a local user, it must be created on both machine with the same password.

      robocopy /s /e /v /c “D:\TestFile” “\\ServeraName\SharedFolderName\TestFile”

    • Scott H

      For your destination, make sure that you specify a file share for the UNC path. For your example to work, you would have had to share out your D drive. I would suggest sharing out the destination folder not the entire drive. Something like this – \\server name\Test File

      Also, make sure your user account has permission to access and write to the file share on the destination server.

  • Me

    You don’t want to use \\servername\D:\
    You should use \\servername\D$\

    That should do the trick for you.

  • dave.o

    not to mention, robocopy is faster at copying data over a network. the simplified syntax I use often is (ex.): C:\robocopy c:\users\userid\documents g:\tempfolder\documents /E /S /W:1 /R:1

  • bohlar

    Robocopy doesn’t like directories or file names with spaces. How to handle this?

    • burner12345

      If you include the robocopy.exe path in quotes that will allow you to use folders with spaces, just did some tests and was able to get it to work.

      if you had a folder by the name of “test folder” and you wanted to copy to “new folder” (without quotes)

      e.x. robocopy.exe “C:test folder” “C:new folder”

      would give you the output:

      source = C:test folder
      Dest: C:new folder

      If you need to include any optional switches, include those outside of the quotes
      e.x. robocopy.exe “C:test folder” “C:new folder” /E /IS

  • Naren Sai

    I tried to copy the data from my hard disk to server by using the following command
    C:Administrator> F:Testtest E:ServerDataZ. Do not open /e
    But only the folders are getting copied not the complete data available in the hard disk.

    Please suggest me what is the correct command to be used to copy the entire data.
    Thanks in advance.

  • JimYab

    I have a CD that I created, with 25 folders of data files. I want to make an image back up of that CD and do not know how to do it. I have two optical drives and want to copy from one and paste to the other in one operation if possible.

  • Anon Wibble

    There’s so many adverts for malware on this page i literally can’t find the robocopy link anywhere.

    • lol

      robocopy link? Read the first sentence of the article again.

Pin It on Pinterest

Share This

Share This

Share this post with your friends!