Today I am going to provide an example of a Robocopy script I use to copy files, retain security, attributes and provide multi-treaded copying for improved performance.
Script:
robocopy <source> <destination> /E /COPYALL /R:1 /W:5 /MT
Let’s break down the options used in this command.
- <source>: The path the source directory you want to copy from.
- <destination>: The path to the destination directory you want to copy to.
Options used:
- /E : Copies all subdirectories, including empty ones
- /COPYALL : Copies all file information, including timestamps, Security Attributes and ownership.
- /R:1 : Specifies the number of retries on failed copies (1 in this example)
- /W:10 : Specifies the wait time between retries in seconds (5 seconds in this example)
- /MT :Enables multi-threaded copying, which improves performance by utilizing multiple threads.
Example:
robocopy C:\DataFiles \\RemoteServer\SharedFolder /E /COPYALL /R:1 /W:5 /MT
In this example, all files and subdirectories from ‘C:\DataFiles’ will be copied to the remote location on another server ‘\\RemoteServer\SharedFolder’ without deleting any files. I hope this example helps someone that needs a quick script to copy files to a local or remote location using a fast copy method. You can speed the copy up if you remove /R:1 and /W:5, robocopy will just skip over files that are locked or cannot be copied.



