How To Use Robocopy In Windows 10

Robocopy is a powerful command-line in Windows operating system that allows users to copy files, folders and partitions. It was first introduced in the Windows NT operating system as part of a resource kit in late 1993. It was continued in later versions such as Windows 2000, Vista, Windows 7, 8 and 10. Although it was not part of Windows XP and Windows Server 2003, users always had an option to independently download an official toolkit from the Microsoft Download Center.

Usage On Windows 10

Opening Command Prompt

First and foremost, you must open Command Prompt tool in order to use Robocopy. 

Some folders/ files may require you to obtain administrative privileges. Therefore, it is recommended to run elevated Command Prompt. The steps are outlined below:

  1. Press the Windows Key.
  2. Type Command Prompt in the Search box.
  3. Right-click on Command Prompt, and select Run as Administrator.

1. Copy An Entire Directory

The following command will copy an entire directory, including all files and sub-folders. You may use this command to backup your documents and files to a different partition, external hard disk or a USB stick.

Syntax

  • Robocopy <Source Directory> <Destination Directory>

Example

  • Robocopy C:\Users\Vikas\Documents D:\MyFiles

2. Copy An Entire Directory & Retain Folder Structure

The following command will deep copy your entire directory while retaining folder structure. Your files will continue to appear in the same hierarchical tree structure as earlier.

Syntax

  • Robocopy /S /E <Source Directory> <Destination Directory>

Example

  • Robocopy /S /E  C:\Users\Vikas\Documents D:\MyFiles

3. Copy An Entire Directory Except Empty Folders & Retain Original Folder Structure

Just like the above command, this will copy an entire directory while retaining its original folder structure. The only difference is that this command will not copy empty folders, if any, from the source directory.

Syntax

  • Robocopy /S <Source Directory> <Destination Directory>

Example

  • Robocopy /S C:\Users\Vikas\Documents D:\MyFiles

4. Self-destructible Directory Copying

Self-destructible Directory Copying copies an entire directory to a different location and then deletes the source directory including all of its contents.

Syntax

  • Robocopy /MOVE /S /E <Source Directory> <Destination Directory>

Example

  • Robocopy /MOVE /S /E C:\Users\Vikas\Documents D:\MyFiles

5. Self-destructible File Copying

The following command will copy an entire directory to the target location and then delete all files from the source directory.

Syntax

  • Robocopy /MOV /S /E <Source Directory> <Destination Directory>

Example

  • Robocopy /MOV /S /E C:\Users\Vikas\Documents D:\MyFiles

6. Mirror Copying

The following command will create a replica of the source directory into the target directory. Be careful that it will delete additional files from the target directory that are not part of the source directory.

Syntax

  • Robocopy /MIR <Source Directory> <Destination Directory>

Example

  • Robocopy /MIR C:\Users\Vikas\Documents D:\MyFiles

7. Copy Directory & Change Folder Attributes

This command will copy an entire directory to the target folder. After successful completion, it’ll change attribute of the target folder.

Syntax

  • Robocopy /S /E /<New Folder Attributes/ Combinations> <Source Directory> <Destination Directory>

Example

  • Robocopy /S /E /R+:H C:\Users\Vikas\Documents D:\MyFiles

(The R+:H switch will apply Read-Only and Hidden attributes to the target folder)

The codenames for popular file attributes are as further:

  • R: Read-Only File
  • H: Hidden File
  • C: Compressed File (Zip)
  • T: Temporary File
  • E: Encrypted File
  • A: Archived File
  • S: System File

Hello, My name is Vikas. I am a technology enthusiast and have an experience of over 6 years in providing technical support in the form of contributing in technology forums, websites, and blogs. I am working with Sorcim Technologies and writing technical content for the company. You can contact me about the content I wrote. Please send an email to the support team (use the support form) and mention my name in the subject, and ask anything related to the content I wrote.

Vikas

Hello, My name is Vikas. I am a technology enthusiast and have an experience of over 6 years in providing technical support in the form of contributing in technology forums, websites, and blogs. I am working with Sorcim Technologies and writing technical content for the company. You can contact me about the content I wrote. Please send an email to the support team (use the support form) and mention my name in the subject, and ask anything related to the content I wrote.