How to exclude files and folders with Robocopy in Windows 10

On Windows 10, Robocopy is a powerful command-line file management tool. In this guide, you'll learn the steps to copy data with Robocopy on Windows 10, except for unnecessary files and folders.

In Windows 10, Robocopy (Robust File Copy) is a powerful command-line file management tool, with a range of options for moving files and folders to another location faster and more reliably than using File. Explorer.

In this guide, you'll learn the steps to copy data with Robocopy on Windows 10, except for unnecessary files and folders.

How to exclude directories with Robocopy

To exclude a folder while copying using Robocopy, use the following steps:

1. Open Command Prompt with admin rights.

2. Enter the following command to copy files and folders, except for a specific folder, to another location and press Enter:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD "C:sourcefolderpathtoexclude-folder"
Picture 1 of How to exclude files and folders with Robocopy in Windows 10
How to exclude directories with Robocopy

This example excludes a specific directory using Robocopy:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD exclude-folder-1

This example excludes a directory using the Robocopy wildcard option:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD exclude-fold*

This example excludes multiple directories using Robocopy:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD "C:sourcefolderpathtoexclude-folder-1" "C:sourcefolderpathtoexclude-folder-2"

When you complete the steps, all data from the path will be copied, except for the directories you specified in the exclude_folder_file_robocopy command .

How to exclude files by Robocopy

To exclude a file while copying using Robocopy, follow these steps:

1. Open Command Prompt with admin rights.

2. Enter the following command to copy files and folders, except for a specific file, to another location and press Enter:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF "C:sourcefolderpathtofolderfilename.extension"
Picture 2 of How to exclude files and folders with Robocopy in Windows 10
How to exclude files by Robocopy

This example excludes a file using Robocopy:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF filename-1.extension

This example excludes a file using the Robocopy wildcard option:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF filena*

This example excludes multiple files using the Robocopy option:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF "C:sourcefolderpathtofolderfilename-1.extension" "C:sourcefolderpathtofolderfilename-2.extension

After completing the steps, Robocopy will copy all files and folders from a specific location, except for the files you specified in the command using the / XF switch .

How to exclude files and folders with Robocopy

To exclude both files and folders using Robocopy, use the following steps:

1. Open Command Prompt with admin rights.

2. Enter the following command to copy all files and folders, except for certain files and folders, to another drive, then press Enter:

robocopy C:sourcefolderpath D:destinationfolderpath /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD "C:sourcefolderpathtoexclude-folder" /XF "C:sourcefolderpathtofolderfilename.extension"
Picture 3 of How to exclude files and folders with Robocopy in Windows 10
How to exclude files and folders with Robocopy

When you complete the steps, all the content will be copied to the new location, in addition to the files and folders you excluded in the command using the / XD and / XF switches .

Update 07 May 2020
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile