Search code examples
windowsbatch-filebatch-processing

Difference between xcopy and robocopy


I'm kind of new to batch scripting. As a newbie I find both both of them useful while scripting What are the key differences between xcopy and robocopy?


Solution

  • Robocopy replaces XCopy in the newer versions of windows

    1. Uses Mirroring, XCopy does not
    2. Has a /RH option to allow a set time for the copy to run
    3. Has a /MON:n option to check differences in files
    4. Copies over more file attributes than XCopy

    Yes i agree with Mark Setchell, They are both crap. (brought to you by Microsoft)


    UPDATE:

    XCopy return codes:

    0 - Files were copied without error.
    1 - No files were found to copy.
    2 - The user pressed CTRL+C to terminate xcopy. enough memory or disk space, or you entered an invalid drive name or invalid syntax on the command line.
    5 - Disk write error occurred.
    

    Robocopy returns codes:

    0 - No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized.
    1 - One or more files were copied successfully (that is, new files have arrived).
    2 - Some Extra files or directories were detected. No files were copied Examine the output log for details. 
    3 - (2+1) Some files were copied. Additional files were present. No failure was encountered.
    4 - Some Mismatched files or directories were detected. Examine the output log. Some housekeeping may be needed.
    5 - (4+1) Some files were copied. Some files were mismatched. No failure was encountered.
    6 - (4+2) Additional files and mismatched files exist. No files were copied and no failures were encountered. This means that the files already exist in the destination directory
    7 - (4+1+2) Files were copied, a file mismatch was present, and additional files were present.
    8 - Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further.
    16 - Serious error. Robocopy did not copy any files. Either a usage error or an error due to insufficient access privileges on the source or destination directories.
    

    There is more details on Robocopy return values here: http://ss64.com/nt/robocopy-exit.html and XCopy here: https://ss64.com/nt/xcopy.html