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?

You can't directly exclude folders or files using the /EXCLUDE option in the xcopy command. However, you can use the /EXCLUDE option with a file that contains the list of files and folders to exclude, one per line. Create a text file, for example, "exclude.txt", and list the paths to the files and folders you want to exclude, one per line, like this: "C:\My Music", "C:\My Pictures". Then, use the xcopy command like this: `xcopy c:\t1 c:\t2 /EXCLUDE:exclude.txt`. This should exclude the specified files and folders from the copy operation.

The Windows command Xcopy allows you to copy files and directories, including subdirectories, to another location. Microsoft provides various examples of using Xcopy in different situations. However, some users have encountered issues where files specified to be excluded by the Xcopy command are still copied, or the command fails to read certain files.

To exclude files in a folder when using xcopy, you can use the `/EXCLUDE` option followed by the path to a file containing the file names to exclude, one per line. For example: `xcopy /EXCLUDE:exclude.

exclude folders xcopy

How to Let Xcopy Exclude Folders and Files Correctly

Microsoft's /exclude option specifies a list of files containing strings, where each string is on a separate line. If any string matches any part of the absolute path of a file to be copied, that file will be excluded from the copy operation. For instance, specifying a string like \obj\ will exclude all files under the obj directory, while .obj will exclude all files with the .obj extension.

To exclude files, you need to write the full path of the files you want to exclude in a text file, then run the command with the path to that text file. For example, if you have a file named "exclude.txt" containing the full path of the files you want to exclude, you can run the command with the path to that file like this: `rsync -avz --exclude-from=/path/to/exclude.txt /source /destination`.

Create a text file named "MyExclusion" in a location of your choice.

2. To exclude specific files or folders from being copied, open the text and write the names of the files or folders you'd like to exclude on a separate line, without bullets, to make xcopy ignore them.

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

Many users find it easy to copy files and exclude specific files and folders using Xcopy. However, aside from the issue of excluding specific folders, other problems with Xcopy have been reported, such as invalid paths, access denied errors, and inability to create directories. As a result, many users are searching for an Xcopy alternative online.

To exclude files during Windows backup copying, use the `wbadmin` command with the `/excludefile` option. For example, to exclude the `C:\Users\YourUsername\AppData\Local\Temp` directory and the `C:\Program Files\YourProgram.

Exclude Folders and Files from Windows Backup with Easier Way

To exclude certain files or folders in a directory while copying, Qiling Disk Master Professional can help. This software is compatible with all versions of Windows 11/10/8/7/XP/Vista and provides the functionality to exclude specific items during the copying process.

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. To sync files, connect your external destination storage to your PC in advance. Then, launch the software and click on "Tools and utilities" followed by "File Sync" (or choose another sync option as needed).

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 extensions you'd like to exclude. Wildcards are supported, and you can separate multiple masks with semi-colons, such as .doc;.xls;.ppt;.temp;.tmp;.bak;~. *;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: The schedule modes can be set to daily, weekly, monthly, or triggered by specific events, and can also be activated by plugging in a USB device.

Qiling Disk Master Professional is a backup and sync tool that also functions as a disk cloning software, allowing users to clone operating systems to SSDs, hard drives to SSDs, and more, with advanced operations also possible via Command Prompt for computer-savvy users.

Conclusion

You can use xcopy to exclude folders or files in a folder while copying from one directory to another. Alternatively, you can use a more comprehensive tool for file backup or syncing that allows for exclusion. A robust backup solution like Qiling Disk Master has earned a good reputation among millions of users and is featured on famous websites like CNET, providing an 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!


QilingTech uses cookies to ensure you get the best experience on our website.  Learn more  Got it