“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?
How to Let XCopy Exclude Folders and Files
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 match 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. Nevertheless, except for the xcopy exclude specific folder issue, there are many other xcopy problems like xcopy invalid path, xcopy access denied, and xcopy unable to create directory, etc. are discussed. That’s why so many people 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 in folders or just folders in directory while copying, AOMEI Backupper Professional comes to help.
File Backup and File Sync: make file recovery and transfer quite easy. You can back up or sync 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.
What’s more, it has a lucid graphical user interface and also gives the way to schedule backup or sync. Real-time file syncing is provided as well. Windows 10/8/7/XP/Vista are supported and you may want to have a try now.
Steps to exclude folders from Windows backup via AOMEI Backupper:
Step 1. Get the free trial, install and run AOMEI Backupper. Connect the external destination storage to your PC in advance if you want to sync files to an external drive.
Step 2. Click Sync tab and select Basic Sync from there.
Step 3. Edit the task name if needed. Click Add Folder to add the folder you’d like to sync.
Step 4. After the source folder is added, click the funnel icon to open Filter settings.
Step 5. Now, you come to the step to add files you’d like to exclude (the files should be included in the selected folder). Click OK after the configuration.
Step 6. Select the destination you’d like to copy files to.
Step 7. Confirm the operation and then click Start Sync.
- 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.
AOMEI Backupper Professional also supports clone operating system to SSD, clone hard drive to SSD, backup system to USB drive, backup external hard drive, and more. More importantly, these operations can be done in Command Prompt.
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.