How to Exclude Files/Folders with Xcopy (Guide and Alternative)  

How to Exclude Files/Folders with Xcopy (Guide and Alternative)


Table of Contents
  1. User Case: How can I exclude folders/files using Xcopy?
  2. How to Let Xcopy Exclude Folders and Files Correctly
  3. Exclude Folders and Files from Windows Backup with Easier Way
  4. Conclusion

User Case: How can I exclude folders/files using Xcopy?

“I’d like to copy files and folders in a directory to another folder excluding a list of files and folders. Run this command: xcopy c:\t1 c:\t2 /EXCLUDE: /My Music /My Pictures’ without quotes but with no luck. It keeps saying ‘can’t read files: /My Music /My Photos’. Is that even possible to make xcopy exclude folders or files while copying? If yes, what should I do to achieve?”

Xcopy, a useful Windows command, allows you to copy files and directories including subdirectories to another place. Microsoft also provides many xcopy command examples for users in different situations. However, some users find xcopy does not exclude files that were written behind EXCLUDE command, or the files cannot be read.

Then, what is the proper way of letting xcopy exclude files in folder when copying?

exclude folders xcopy

How to Let Xcopy Exclude Folders and Files Correctly

According to Microsoft, /exclude specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings matches any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively.

To be specific, you need to write all files that need to be excluded in separate line in a text file, and name it. Write the FULL PATH instead of the NAME of the text file next to the command /exclude. Here is an example based on the user in the case at the beginning.

1. Create a text file and name it with MyExclusion for example, regardless of the location.

2. Open the text and write the files’ name you’d like to exclude in a separate line like this (without bullets) to make xcopy exclude multiple folders.

3. Run the command now: xcopy c:\t1 c:\t2 /EXCLUDE: C:\mybatch\MyExclusion.txt and press Enter.

It is quite easy to copy files and exclude some certain files and folders with Xcopy. However, except for the Xcopy exclude specific folder issue are discussed, such as there are many other Xcopy problems like Xcopy invalid path, Xcopy access denied, Xcopy unable to create directory, etc. That’s why many users are looking for Xcopy alternative on the Internet.

As a matter of fact, we have easier way to let Windows backup exclude files during copying.

Exclude Folders and Files from Windows Backup with Easier Way

To exclude certain files or folders in directory while copying, Qiling Disk Master Professional comes to help. It works with all versions of Windows 11/10/8/7/XP/Vista, and offers you the following:

What’s more, it has a lucid graphical user interface and allows for scheduled backup or sync to save your labor. Download and install the free trial to get started:

Steps to exclude folders from Windows backup via Qiling Disk Master:

Step 1. Connect the external destination storage to your PC in advance if you want to sync files to an external drive. Then launch the software, and Click Tools and utilities -> File Sync (you can choose other Sync options as you need).

File Sync

Step 2. Edit the task name if needed. Click Folder to add the folder you’d like to sync.

Add Folder

Step 3. After the source folder is added, click the funnel icon to open Filter settings.

Click Filter

Now, you come to the step to add file extentions you’d like to exclude. The wildcards are supported here, and you can separate multiple masks with semi-colons, such as,*.doc;*.xls;*.ppt.*.temp;*.tmp;*.bak;*~*. *temp;temp*.

Click OK after the configuration.

Step 4. Select the destination you’d like to copy files to.

Select Destination

Step 5. Confirm the operation and then click Proceed.

Proceed

Notes:✎...
Options: write a comment for current task and enable email notification here.
Schedule: set schedule modes from daily, weekly, monthly, event triggers, and USB plug in here.

Qiling Disk Master Professional is not only a backup & sync tool, but also a disk cloning software. It supports clone operating system to SSD, clone hard drive to SSD, backup system to USB drive, backup external hard drive, and more. If you are computer savvy, these operations can also be done via Command Prompt.

Conclusion

You can let xcopy exclude folders or files in folder while copying from one directory to another with simple steps. Likewise, you have better choice to do exclusion during file backup or file syncing with a comprehensive tool. As a robust backup solution, Qiling Disk Master earns good reputation among millions of users and many famous websites like CNET. Go for it to add extra layer of protection for your computer.

Related Articles


Is this information helpful?     

What can we do to improve this information? (Optional)
Refresh Please enter the verification code!