Computershowsoftware

How To Exclude folder And Fil using Robocopy on Windows

On Windows 11 or window10 Robocopy (Robust File Copy) is a powerful file management command line tool with many options to move files and folders to another location faster and more reliable than File Explorer.

However, by default, Robocopy moves everything along a specific path, which may not be perfect every time
Where you may have specific files and folders in a location that you don’t want to copy.
However, the tool includes at least two options, which you can use to exclude files and folders from the burning process.

In this guide, you will learn the steps to copy data with Robocopy on Windows 10 (or Windows 11), except for those files and folders that you don’t need to move

Exclude a folder using Robocopy

To exclude a folder while copying with Robocopy, use the following steps:
Open Start on Windows 11.
Find Command Prompt, right-click the result, and select the Run as administrator option.
Type the following command to copy files and folders, except for a specific folder, to another location and press Enter
robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD “C:\source\folder\path \to\exclude-folder”

This example excludes a specific folder using robocopy :
robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD exclude-folder-1

This example excludes a folder that uses the option:
robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD exclude-fold*

This example excludes multiple folders using Robo Copy:

robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD “C:\source\folder\path \to\exclude-folder-1” “C:\source\folder\path\to\exclude-folder-2”

Once the steps are completed, the data will be copied to the destination
Except for the folders specified in the command (exclude_folder_binary_version) to be excluded.

Exclude a file with Robocopy

To exclude a file while copying with Robocopy, use the following steps:

  • Open the Start menu.
  • Find Command Prompt, right-click the result, and select the Run as administrator option.
  • Type the following command to copy files and folders, except for a specific file, to another location and press Enter

robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF “C:\source\folder\path \to\folder\filename. extension”

This example excludes a file using Robo Copy Automated Copy:
robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF filename-1.extension

This example excludes a file with an option:
robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF filena*

This example excludes multiple files with an option:

robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF “C:\source\folder\path \to\folder\filename-1.extension” “C:\source\folder\path\to\folder\filename-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 with the /XF switch.

Exclude files and folders with Robocopy

To exclude a file and folder using Robocopy, use the following steps:

Open the Start menu.
Find Command Prompt, right-click the result, and select the Run as administrator option.
Type the following command to copy files and folders, except for certain files and folders, to another drive and hit Enter:


robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XD “C:\source\folder\path \to\exclude-folder” /XF “C:\source\folder\path\to\folder\filename.extension”

Once you complete the steps, all content will be copied to the new location except for those files and folders that you excluded in the command using the /XD and /XF switches.

Robocopy command keys

Robocopy has a lot of options and in the command given in this guide we use the following keys to make data copies

Except for certain files and folders
/E Copies subdirectories, including empty directories.
/Z – Copy files in restart mode.
/zb – Uses restart 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 trying again (you can specify a different number, the default is 30 seconds).
/TBD – Wait for share names to be defined (retry error 67).
/ NP – no progress – does not display the copied percentage.
/V – Produce verbose output, showing skipped files.
/XD – Excludes folders matching the path and folder name.
/xf – Exclude files matching the location and filename.

The most important switches for this command are /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 as you should in any standard copying process with Robocopy.

see : how-to-repair-windows-system-files-using-sfc-and-dism/

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button