[batch-file] /exclude in xcopy just for a file type

I have a batch file to copy over files from Visual Studio to my Web folder. I want to copy all files in my web project, EXCEPT for *.cs files. I can't seem to get this to work:

xcopy /r /d /i /s /y /exclude:".cs" C:\dev\apan C:\web\apan

Any tips? I just get exit code 4 when I try to run this.

This question is related to batch-file xcopy

The answer is


For excluding multiple file types, you can use '+' to concatenate other lists. For example:

xcopy /r /d /i /s /y /exclude:excludedfileslist1.txt+excludedfileslist2.txt C:\dev\apan C:\web\apan

Source: http://www.tech-recipes.com/rx/2682/xcopy_command_using_the_exclude_flag/


In my case I had to start a list of exclude extensions from the second line because xcopy ignored the first line.


Change *.cs to .cs in the excludefileslist.txt