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"

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"

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"

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
- 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
May be interested
- Tricks to hide files or folders on Windows, Mac OS X and Linuxhiding, hiding folders or files on your computer partially ensures the security of the information contained in the folder or files that are not found by others.
- How to enable / disable the Security tab of files and folders on Windows?on ntfs-formatted hard drive partitions, you can set security permissions for files and folders. this permission allows you to access or deny access to files and folders. to set security for files and folders, please refer to the steps in the following article of network administration.
- How to Show Hidden Files in Windows 7windows 7 hides important folders and files in order to keep users from modifying or deleting their files and subsequently damaging their systems. windows 7 does not show hidden files by default. for example, the pagefile.sys file is a...
- How to interact with files and contacts in Gomastering how to use the file system with the useful functions below will greatly help your work. here's how to interact with files and folders in go .
- How to delete files and folders on Dropboxafter a long time using dropbox leads to more and more storage space on dropbox. you should clean up dropbox, delete files or folders that are no longer in use.
- How to decrypt files and folders on Windows 10in today's world of rampant hacking and data theft, keeping files encrypted is one of the few viable ways to protect them from abuse.
- 5 Windows files and folders can be deleted to free up spacewindows contains many unnecessary files and folders from hidden cache, old files you can delete them to free up space. but to know whether it is safe to delete folders and files is safe.
- How to compress and decompress files and folders on a Macon the mac, there is a built-in tool to compress and decompress files and folders that users do not need to install the application, if only the basic compression and decompression features.
- How to bookmark folders on Windows 10if you organize your folders, you won't have to struggle to find important files. you can bookmark your favorite folders in windows 10 for easy access. here are a few ways you can do that.
- Restore hidden folders in Windows when infectedin many cases it is often the virus that attacks the system's hidden folders that cannot be displayed even if you have enabled the 'show hidden files and folders' option in folder options. some of the following methods will help solve this problem.