Robocopy command is a command which is used on Windows to copy files or directories from one place to another. Also, this CMD command prints a detailed report of the copy operation. In the text below, you are able to find examples for using Robocopy in various use cases.
RoboCopy or Robust File Copy is a command-line file copying tool in Windows. It is designed for trusted copying of directories anywhere the computer has access, including removable drives, local drives, Local Area Network, and remote servers. In the process make sure that all file properties and permissions stays intact. Also, RoboCopy supports resume copying feature to pick up where it left off on network disconnect. It means that once a copy fails at 99% you are only able to finish the last bits which were not copied. It has a useful command line progress indicator too that comes useful while copying large files.
Based on the research, Robocopy was available for free download with the Windows Resource Kit since Windows 2000 or Windows NT version 4.0. But, it has never been an official feature of the operating system until the arrival of Vista. Until now, it works on the following Operating Systems: Windows Vista, Windows Server 2008, Windows Server 2003, Windows 8, Windows 7, Windows XP, and Windows 2000 or Microsoft Windows NT 4.0.
ROBOCOPY SYNTAX AND EXAMPLES
robocopy source destination [file [file] … ] [parameters]
- source: determine source folder. You are able to use drive:\path or \\server\share\path.
- destination: determine destination folder. You are able to use drive:\path or \\server\share\path.
- file: Files to process. The wildcard characters are supported.
- parameters: Command-line switches you want to use. You are able to find the entire list at the end of this article.
Example 1 – This is a simple Robocopy command:
robocopy C:\Folder1 C:\Backup
robocopy \\sourceserver\path \\destinationserver\path
This command is going to copy all files in C:\Folder1 to C:\Backup. Sub-folders are excluded. To copy all files and sub-folders recursively, you are able to use this command:
robocopy C:\Folder1 C:\Backup /E
Example 2 – Copy a single file:
robocopy C:\Folder1 C:\Backup myfile.xlsx
Example 3 – This is only copy a specific file from source to destination:
robocopy C:\Folder1 C:\Backup *.docx /E
Example 4 – Mirroring source folder to destination:
robocopy C:\Folder1 C:\Backup /MIR
This command is going to mirror C:\Folder1 to C:\Backup. While doing that, it is able to remove any file or folder in the destination folder which is not present in source.
Example 5 – Mirror folders, while maintaining all pre-existing files and folders in destination.
robocopy C:\Folder1 C:\Backup /MIR /XX
For maintaining specific file or folder use /XF (file) or /XD (folder) parameter.
robocopy C:\Folder1 C:\Backup /MIR /XD “C:\Backup\Old”
Example 6 – Copy only those files and folders which exists in destination, then ignore others:
robocopy C:\Folder1 C:\Backup /S /XL
Example 7: Copy files from source to destination, skip files exist in the destination.
robocopy C:\Folder1 C:\Backup /S
This is able to be useful to save time as well as to prevent loss of existing file data or properties.
Example 8 – List files of specific size:
robocopy C:\Folder1 C:\Backup /MAX:33554432 /L
This is going to list files larger than 32MB. You will be able to use /MIN for smaller than 32MB files.
Example 9 – Copy only those files which are older or newer than specified days:
robocopy C:\Folder1 C:\Backup /E /MINAGE:7
This command copies only the files which are older than 7 days. To choose only newer files you are able to use /MAXAGE.
Example 10 – Mirror folders by allowing resume function, ignore hidden files, and reduce wait time between failures:
/Z : Allows resume of while from without starting from beginning.
/XA:H : Ignore the hidden files.
/W:5 : Lower wait time between failures to five seconds.
Example 11 – Monitor and synchronize on change in source automatically:
robocopy C:\Folder1 C:\Backup /MON:1 /R:10
This command will re-saves every time a change is made. Enhance the value of /MON to change number before sync is executed. You are able to use /R to specify retries.
Example 12: Allow multi-threaded support:
robocopy \\sourceserver\share\path C:\Backup /MIR /MT[:n]
In this example command, you have to note that ‘n’ order Robocopy to do multi threaded copies using ‘n’ threads.
Robocopy copies files or folders in multi-threaded operation by default. If you wish, you are able to increase its value by using /MT switch.
Robocopy is known for capabilities above and beyond the built-in Windows copy and xcopy commands. In addition, now we are going to share some other features of Robocopy. Here are those features:
- Robocopy has ability to let network interruptions and resume copy.
- Robocopy has ability to skip NTFS junction points which is able to cause copying failures as of infinite loops.
- Robocopy has ability to copy file data and attributes properly, and to preserve original timestamps, as well as owner information, NTFS ACLs, and audit information by using the /COPYALL or /COPY: command line switches.
- Beginning with the XP026 version, Robocopy has ability to copy folder or directory. Even with the ability to update folder timestamps on folders already made from previous versions.
- Robocopy has ability to assert the Windows NT “backup right”, so an administrator can copy an entire directory such as files denied readability to the administrator.
- Robocopy is Persistence by default. Of course, this feature will benefit for you.
- Robocopy has a mirror mode that keeps trees synchronised by removing files in the destination which are not present in the source.
- Robocopy has ability to skip files already in the destination folder with equal size and timestamp.
- Robocopy has ability to copy paths exceeding 259 characters, up to a theoretical limit of approximately 32,000 characters without any errors.
- Robocopy has a multithreaded copying that introduced with Windows 7 and Windows Server 2008.
On my daily job, I am a software engineer, programmer & computer technician. My passion is assembling PC hardware, studying Operating System and all things related to computers technology. I also love to make short films for YouTube as a producer. More at about me…