How to exclude files and folders with Robocopy in Windows 10
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"
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"
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"
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 .
You should read it
- Robocopy command in Windows
- Use multi-threaded Robocopy feature to speed up file copying on Windows 10
- A simple way to delete a folder with a long name on Windows
- Windows 11 adds a policy to exclude USB from BitLocker encryption
- Instructions for setting password to protect files and folders in Windows
- Instructions for hiding files and folders in Windows 10 Search
- How to show hidden files, hidden folders in Windows 10, Windows 7
- Tricks to hide files or folders on Windows, Mac OS X and Linux
- How to enable / disable the Security tab of files and folders on Windows?
- How to Show Hidden Files in Windows 7
- How to interact with files and contacts in Go
- How to delete files and folders on Dropbox