However, by default, Robocopy transfers everything on a given path, which may not be ideal in every scenario as you may have specific files and folders in a location you don’t want to copy. However, the tool includes a least two options, which you can use to exclude files and folders from a copy process. In this guide, you will learn the steps to copy data using Robocopy on Windows 10 (or Windows 11), excluding those files and folders you don’t need to transfer.

Exclude folder using Robocopy Eexclude file using Robocopy Exclude files and folders using Robocopy

Exclude folder using Robocopy

To exclude a folder while copying with Robocopy, use these steps: Once you complete the steps, the data will copy to the destination, except the folders specified in the command (exclude_folder_file_robocopy) to be excluded.

This example excludes a specific folder using Robocopy: This example excludes a folder using the Robocopy wildcard option: This example excludes multiple folders using Robocopy:

Exclude file using Robocopy

To exclude a file while copying with Robocopy, use these steps: After you complete the steps, Robocopy will copy all the files and folders from a particular location, excluding the files you specified in the command using the /XF switch.

This example excludes a file using Robocopy: This example excludes a file using the Robocopy wildcard option: This example excludes multiple files using the Robocopy option:

Exclude files and folders using Robocopy

To exclude a file and folder using Robocopy, use these steps: Once you complete the steps, all the content will copy to the new location except those files and folders you excluded in the command using the /XD and /XF switches.

Robocopy command switches

Robocopy has a lot of options, and in the command shown in this guide, we’re using the following switches to make copy data, excluding specific files and folders.

/E — Copy Subdirectories, including empty ones. /Z — Copy files in restartable mode. /ZB — Uses restartable mode. If access is denied, use backup mode. /R:5 — Retry 5 times (you can specify a different number, the default is 1 million). /W:5 — Wait 5 seconds before retrying (you can select a different number, the default is 30 seconds). /TBD — Wait for share names To Be Defined (retry error 67). /NP — No Progress – don’t display percentage copied. /V — Produce verbose output, showing skipped files. /XD — Excludes folders matching the path and folder name. /XF — Excludes files matching the location and file name.

The most important switches in this command are the /XD which allows you to exclude folders, and /XF, which you can use to exclude files. The other options are optional, but you should use these options that you should use in any standard copy process using Robocopy. All content on this site is provided with no warranties, express or implied. Use any information at your own risk. Always backup of your device and files before making any changes. Privacy policy info.