robocopy

Robocopy - How to copy All Files & Folders and Run Command Again and Only Copy Changed Files and Keep Permissions

This tutorial describes how to use robocopy to copy all files and folders from a source to a destination. With the same command, you can run it again later, and it will only copy files that have changed to the destination. Also, if files were deleted from the source, it will remove them from the destination as well. This command will also keep all of the NTFS permissions and file attributes.

A typical use scenario for this command is copying a large file share. You can run the command once to copy the bulk amount of the data, then you can run it again later, and it will only copy changed files, which will make it much faster.

robocopy C:\source C:\dest /TEE /LOG+:c:\robolog.txt /MIR /copyall /zb /w:1 /r:2 /xo

First, I'll show you examples of this command in action, and then I'll break the command down to show you what each part does. (Make sure to launch the command prompt as administrator)

In the image below, you see a source and destination directory. The source has multiple folders with data in them. The destination is empty.

Robocopy - How to copy All Files & Folders and Run Command Again and Only Copy Changed Files and Keep Permissions - 1

How to Robocopy File Shares With Spaces

You will see the following error if you try to use robocopy to transfer data to or from a network share with spaces in it unless you use the correct syntax:

robocopy spaces

ERROR 67 (0x00000043) Getting File System Type of Source \\servername\share name" e:\data \s \e \copy:dats

The network name cannot be found.

ERROR : No Destination Directory Specified.

To resolve the error, you must use the correct robocopy syntax for shares with spaces. This is the correct syntax for my example:

robocopy /"\server01\boe applications\/" e:\data \s \e \copy:dats

Just in case you were wondering what the switches in this command do, here is a description:

robocopy source destination

/s & /e - Copy subdirectories

/copy:dats - Copies the following file properties: Data, Attributes, Time Stamps, and NTFS ACL

Subscribe to robocopy