less than 1 minute read

tl;dr: If you pass a txt file listing the items to exclude to the /exclude: option of xcopy, you can copy while excluding multiple files and directories.

Here is how to exclude multiple directories and files when copying with xcopy.

When you use the exclude option, you don’t pass a file name or a directory name but rather a txt file:

rem xcopy command
xcopy src-path destination-path /exclude:.\exclude-list.txt

In the txt file, you list the directories or files.

# .\copy-exclude-list.txt
\.git\ # exclude directory
.css # exclude CSS files
test* # exclude file names starting with test
# and so on

Done!

Tags:

Categories:

Updated:

Leave a comment