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

Wondering how to let xcopy exclude folder or files from Windows backup? Here you’ll learn how to do it and another easier way to exclude specific files and folders will be introduced.

Clytze

by Clytze Updated on October 17, 2022

Share this: instagram reddit

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.

  • \My Music\

  • \My Pictures\

  • \My Videos\

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, AOMEI Backupper Professional comes to help. It works with all versions of Windows 11/10/8/7/XP/Vista, and offers you the following:

  • File Backup and File Sync: You can sync or backup files to lots of destinations such as (Seagate) external hard drive, USB flash drive, SD card, CD/DVD disc, NAS, network share, Cloud drive, and so on.

  • Filter Settings: you are allowed to include or exclude files or folders with specific file extensions or wildcards. In addition, you have the choice to exclude hidden and system files and folders at the same time.

  • Advanced Sync: In addition to the basic file sync, you can run Real-Time Sync to autorun it in real time (without schedule) once there are changes in the source directory detected. More sync modes such as Two-Way Sync and Mirror Sync are also available.

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:

Download Free Trial Win 11/10/8.1/8/7/XP
Secure Download

Steps to exclude folders from Windows backup via AOMEI Backupper:

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 Sync -> Basic Sync (you can choose other Sync options as you need).

File Sync

Step 2. Edit the task name if needed. Click Add 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*.

  • File Inclusion Mask: specify the file types that you need to backup. 
  • File Exclusion Mask: specify the file types that you need to exclude. 
  • Folder Exclusion Mask: specifies the folders that you need to exclude. 
  • There are 3 more options: "Include subfolders", "Exclude hidden files and folders" and "Exclude system files and folders". Check them as you want.

Click OK after the configuration.

File Exclusion

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

Select Destination

Step 5. Confirm the operation and then click Start Sync.

Start Sync

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.

As cloud storage is becoming more and more popular, AOMEI offers users its own cloud - AOMEI Cloud. After you sign up for an AOMEI account, you can use 1TB storage for free within 15 days. You can backup all your important stuff to AOMEI Cloud, like documents, pictures and favorite music, etc.

Cloud Backup

AOMEI Backupper 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, AOMEI Backupper 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.

Clytze
Clytze · Editor
Clytze, an editor at AOMEI Technology, is passionate about safeguarding your digital world. She dedicates her expertise to empower users like you in data security and recovery. She firmly believes that everyone should have the tools and knowledge to protect their digital assets through computer backup, seamless disk cloning, and efficient file synchronization. Clytze is your trusted guide on the journey to data safety.