ROBOCOPY command in Windows
Robocopy is a robust file-copying tool in Windows, known for its speed and reliability. With various options for customizing the copying process, Robocopy is a powerful command-line utility for efficiently transferring files and directories. It can handle tasks such as mirroring directories, copying large files with resume capabilities, and synchronizing content between different locations. Robocopy is especially useful for backup and migration scenarios, thanks to its ability to copy file attributes, security settings, and timestamps.
ROBOCOPY Syntax:
Windows ROBOCOPY Options:
Option | Description |
---|---|
/S | Copy subdirectories excluding empty ones |
/E | Copy subdirectories, including empty ones |
/Z | Copy files in restart mode |
/B | Copy files in Backup mode |
ROBOCOPY Parameters:
Parameter | Description |
---|---|
Source | Specifies the path to the source directory |
Destination | Specifies the path to the destination directory |
File | Specifies the file(s) to copy |
Options | Specifies the options to apply during copy |
How to use ROBOCOPY command:
Copy a Folder to Another Location
Copies all contents of “SourceFolder” to “DestinationFolder” including subdirectories.
Mirror a Folder to Another Location
Mirrors “SourceFolder” to “DestinationFolder” by copying all files and directories and deleting any not present in the source.
Copy Files Based on a Certain Date
Copies only files from “SourceFolder” that are 7 days old or newer to “DestinationFolder”.
Display Detailed Progress Information
Displays detailed progress information without listing directories, processing separately per file, and providing verbose output.
Copy Files in Backup Mode
Copies files in “Backup” mode, allowing Robocopy to override security restrictions if necessary.
Exclude Specific Files or Directories
Excludes all .txt files and the “ExcludedFolder” from the copying process.
Copy Files in Restartable Mode
Copies files in “Restartable” mode, allowing Robocopy to resume copying in case of interruptions.
Synchronize Two Directories
Synchronizes “SourceFolder” to “DestinationFolder” using fast file times and unbuffered I/O.
How do I use robocopy in Windows?
To use the robocopy command in Windows, execute the following command:
What are some common options for using robocopy in CMD?
Some common options for using robocopy in CMD include:
How can I copy only new or changed files with robocopy?
To copy only new or changed files with robocopy, use the “/XO” (exclude older) or “/MIR” (mirror) option. For example:
How do I exclude certain files or directories when using robocopy?
To exclude certain files or directories when using robocopy, use the “/XF” (exclude files) or “/XD” (exclude directories) option. For example:
Can I use robocopy to copy files over the network?
Yes, robocopy can be used to copy files over the network by specifying the network path in the source or destination. For example:
How do I copy files with permissions and timestamps using robocopy?
To copy files with permissions and timestamps using robocopy, use the “/COPYALL” option. For example:
How do I display progress while copying files with robocopy?
To display progress while copying files with robocopy, use the “/TEE” (output to console and log file) and “/NP” (no progress) options. For example:
How can I retry copying files that failed with robocopy?
To retry copying files that failed with robocopy, use the “/R” (number of retries) and “/W” (wait time between retries in seconds) options. For example:
How do I log the output of robocopy to a file?
To log the output of robocopy to a file, use the “/LOG” option followed by the log file path. For example:
Applications of the ROBOCOPY Command
- Backup and restore files and directories
- Synchronize files between different locations
- Copy files with specific attributes or properties
- Mirror content of directories
- Copy files with support for resuming interrupted transfers
- Log file copying operations
- Exclude specific files or directories from the copy process
- Copy files and directories with security settings and NTFS permissions preserved
- Multithreaded copying for faster performance
- Copy files and directories with timestamps preserved