+3 votes
3.1k views
How to exclude files and folders in Robocopy Windows

in Windows 10 by (552k points)
reopened | 3.1k views

1 Answer

+4 votes
Best answer

1. How to exclude a folder in Windows 10 with Robocopy
2. How to exclude a file using Robocopy Windows
3. How to simultaneously exclude a file and a folder with Robocopy Windows
4. How to use other parameters with Robocopy Windows

Working with files and folders in Windows 10 is essential on a daily basis in front of the system and although normally we do this using the copy and paste functions there is a command that has been developed exclusively for this purpose and is the Robocopy command in Windows 10 ..

What is Robocopy?
Robocopy (Robust File Copy), is a command with which it is possible to manage files using different usage parameters based on the needs of the case. The difference of this command with the popular copy / paste, is the security and efficiency of the process, but Robocopy transfers everything by default in a single route, which is not viable in special cases. there we can define where we want to move these objects and TechnoWikis will explain how to achieve it.
Advantage
Some of its advantages are:
  • Performs various automatic retries in case of not accessing a particular file.
  • Enable copying of large amounts of files.
  • Integrate a progress indicator.
  • Supports selective copying of objects and more.

The basic syntax of this command is:

 robocopy <Resource> <Destination> [<File> [...]] [<Options>] 
The usage parameters are:
Specify the path to the source directory
 <Resource> 

Indicates the path to the destination directory
 <Destination> 

It allows us to define the file or files to be copied, the use of wildcards (* or?) Is allowed. If desired, the default value is *. \ *
 <File> 

There we can enter the options to use with Robocopy
 <Options> 

The options to use with the Robocopy command are the following:

Copy subdirectories excluding gaps
 / s 

This option copies only the top N levels of the selected source directory tree
/ lev:
 <N> 

Copy subdirectories integrating the gaps
 /and 

Copy files in resettable mode
 / z 

It will copy the files in Backup mode
 / b 

This option allows you to copy the encrypted files in EFS RAW mode
 / efsraw 

It allows us to indicate the properties of the file to be copied as D data, A attributes, T Time stamps, S NTFS access control list (ACL), O Owner information and U Audit information
 copy: <CopyFlags> 

It allows you to indicate what to copy for directories such as D = data, A = attributes or T = timestamps.
 / dcopy: <copyflags> 

Will copy files safely
 / sec 

It allows to correct the security of the files
 / secfix 

This parameter will copy all the information from the file
 / copyall 

Do not copy any information from the file
 / nocopy 

Lets you delete the destination files and directories that are already available at the source
 / purge 

Move the files and then delete them
 / mov 

There are many more parameters that we can visualize with the help command.


1. How to exclude a folder in Windows 10 with Robocopy

Step 1

To do this we access the command prompt console as administrators and we will execute the following syntax:
 robocopy C: \ source \ folder \ path \ D: \ destination \ folder \ path \ / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XD "C: \ source \ folder \ path excluded folder " 
For example, we have on the desktop a root folder called TechnoWikis2 and within it two folders (TechnoWikis3 and TechnoWikis4), we are going to copy this to D: \ TechnoWikis but excluding the TechnoWikis2 folder:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XD "C: \ Users \ solve \ Desktop \ TechnoWikis2" 
image
Step 2

Another way to execute this command is as follows:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XD C: \ Users \ solve \ Desktop \ TechnoWikis2 \ TechnoWikis4 
image
Step 3

If we want to use wild cards, we can execute the following syntax:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XD * C: \ Users \ solve \ Desktop \ TechnoWikis2 \ Solv * 
If we want to exclude more than one folder we can execute the following:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XD "C: \ Users \ solve \ Desktop \ TechnoWikis2 \ TechnoWikis3 "" C: \ Users \ solve \ Desktop \ TechnoWikis2 \ TechnoWikis4 " 
image

2. How to exclude a file using Robocopy Windows

Step 1

We can exclude files based on their extension, for this we go again as administrators to the command prompt console and we will use the following syntax:
 robocopy C: \ source \ folder \ path \ D: \ destination \ folder \ path \ / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XF "C: \ source \ folder \ path .extension" 
For example, let's exclude the file called TechnoWikis.text:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XF "C: \ Users \ solve \ Desktop \ TechnoWikis2 \ TechnoWikis .txt " 
image
Step 2

It will also be possible to use the following syntax:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XF TechnoWikis.txt 
We can use a wild card:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XF Solvet * 
image
Step 3

Like the previous one, we can exclude files with different extensions:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XF "C: \ Users \ solve \ Desktop \ TechnoWikis2 \ TechnoWikis .txt "" C: \ Users \ solve \ Desktop \ TechnoWikis2 \ TechnoWikis.jpg " 
image

3. How to simultaneously exclude a file and a folder with Robocopy Windows


It is possible that in a single command we exclude both a file and a folder thanks to Robocopy, for this we will use the following syntax in our case:
 robocopy C: \ Users \ solve \ Desktop \ TechnoWikis2 D: \ TechnoWikis / E / Z / ZB / R: 5 / W: 5 / TBD / NP / V / XD "C: \ Users \ solve \ Desktop \ TechnoWikis2 \ TechnoWikis3 "/ XF" C: \ Users \ solve \ Desktop \ TechnoWikis2 \ TechnoWikis.txt " 
image

Thus we have excluded the TechnoWikis folder and in passing the TechnoWikis.jpg file..


4. How to use other parameters with Robocopy Windows


In these examples we have used the following parameters but remember that we have many more:
It allows you to copy subdirectories, including gaps
 /AND 

Copy files in resettable mode
 / Z 

It makes use of the resettable mode, only if the access denied uses the backup mode
 / ZB 

It allows an attempt of 5 times to move the files (there we can indicate the desired value, the default value is 1 million)
 / R: 5 

Give a 5 second timeout before retrying the action (the default value is 30 seconds).
 / W: 5 

Wait for the shared names to be defined
 / TBD 

It does not show the percentage copied from the files
 / NP 

Launch the detailed results, showing the skipped files
 / V 

Excludes folders that match the path and name of the folder we have selected
 / XD 

Excludes files that match the path and file name
 / XF 

With Robocopy we have the facility to copy files (even in large quantities) in a safe and reliable way to the various directories of the system.


by (3.5m points)
edited
I had the time to try this and I can say that your solution is working. In the other hand it is easy and not taking much time with the program which I use now, Gs Richcopy 36 surprised me, it can handle such a case and many issues which I faced before with robocopy .

Related questions

+5 votes
1 answer
asked Oct 8, 2019 in Security by backtothefuture (552k points) | 367 views
+5 votes
1 answer
asked Oct 15, 2019 in Windows 10 by backtothefuture (552k points) | 266 views
+4 votes
1 answer
+4 votes
1 answer
+5 votes
1 answer
asked May 28, 2020 in Help by backtothefuture (552k points) | 273 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users