Robocopy Exclude Directory in Windows 10

0
61

In Windows 10, Robocopy (Robust File Copy) is basically a powerful command-line file management tool. Along with a range of options for moving files and folders to another location faster and more reliably than using File. Explorer. In this article, we are going to talk about Robocopy Exclude Directory in Windows 10. Let’s begin!

But, by default, Robocopy transfers everything on a given path, which may not be ideal in every scenario as you may have particular files and folders in a location. That you guys do not want to copy. However, the tool includes a least two options, that you can use to exclude files and folders from a copy process as well.

How to exclude folder using Robocopy | Robocopy Exclude Directory

In order to exclude a folder while copying with Robocopy, use these simple steps:

  • First, open Start on Windows 10.

Search for Command Prompt, right-click the result, and then choose Run as administrator.

  • Type the following command in order to copy the files and folders excluding a particular folder to another location and tap on 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"

Robocopy Exclude Directory

This example excludes a particular 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

In this example excludes a folder via Robocopy wildcard 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 basically excludes multiple folders via Robocopy:

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"

When you complete these steps, then all the data from the path will be copied over excluding the folders. That you specified in the command exclude_folder_file_robocopy.

How can you exclude file using Robocopy | Robocopy Exclude Directory

In order to exclude a file while copying with Robocopy, use these simple steps:

  • First, open Start.
  • Search for Command Prompt, right-click the result, and then choose the Run as administrator option.
  • You have to type the following command to copy the files and folders. Excluding a specific file to another location and tap 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"

Robocopy Exclude Directory

This example excludes a file via Robocopy:

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

In this example, it basically excludes a file via Robocopy wildcard option:

robocopy C:\source\folder\path\ D:\destination\folder\path\ /E /Z /ZB /R:5 /W:5 /TBD /NP /V /XF filena*

This example actually excludes multiple files via Robocopy 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 all of these steps, Robocopy will then copy all of the files and folders from a particular location. Excluding the files, that you specified in the command using the /XF switch.

How can you exclude file and folder using Robocopy | Robocopy Exclude Directory

In order to exclude a file and folder using Robocopy, use these simple steps:

  • First, open Start.
  • Search for Command Prompt, right-click the result, and then choose the Run as administrator option.
  • You have to type the following command to copy the files and folders. Excluding certain files and folders to another drive and then tap on 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"

Robocopy Exclude Directory

When you complete all of these steps, then all of the content will be copied to the new location. Except for those files and folders you excluded in the command using the /XD and /XF switches.

Robocopy command switches explained | Robocopy Exclude Directory

Robocopy has actually a lot of options and in the command shown in this guide. We are using the following switches in order to make copy data excluding certain files and folders.

  • /E — Copy Subdirectories, including empty ones also.
  • /Z — Copy files in restartable mode.
  • /ZB — Uses restartable mode, if access denied then use Backup mode.
  • /R:5 — Retry 5 times (you can specify a different number, default is 1 million).
  • /W:5 — Wait 5 seconds before retrying (you can also specify a different number, default is 30 seconds actually).
  • /TBD — Wait for share names to be defined (retry error 67).
  • /NP — No Progress – do not display the percentage copied.
  • /V — Produce verbose output, showing skipped files.
  • /XD — Excludes folders matching the path and folder name as well.
  • /XF — Excludes files also matching the path and file name.

The most important switches in these commands are the /XD that allows you to exclude folders and /XF that you can use to exclude files as well. The other switches are optional, however, they are recommended options that you should use in any of the standard copy processes via Robocopy.

Conclusion

Alright, That was all Folks! I hope you guys like this Robocopy Exclude Directory article and also find it helpful to you. Give us your feedback on it. Also if you guys have further queries and issues related to this article. Then let us know in the comments section below. We will get back to you shortly.

Have a Great Day!

Also See: All New Windows 10 Update KB4489899

Leave a Reply