Excluding files and folders
A useful feature of Xcopy is the ability to exclude certain files and/or folders from being copied by means of the "/Exclude" switch. All names containing a given string of characters can be excluded. Unfortunately, Microsoft's description of the switch is neither a model of clarity nor accurate. In fact, postings on the Internet indicate considerable confusion exists about how to implement this handy feature. Perhaps the list below will help clarify how to use it.
1. The strings contained in the names of the files and/or folders to be excluded
are not entered directly in the command switch itself.
2. The entry in the command switch is one or more text files that list the strings to be excluded.
3. The format of the switch is /Exclude:{path}list_of_exclusions.txt Note the colon between Exclude and the name of the file that lists the exclusions. Although more than one exclusion file can be used, stick with one if you can.
4. The name of the file that lists exclusions cannot have spaces. Quoting does not help.
5. Be careful with pathnames. Remember that operations are relative to the working directory for the command prompt. I suggest placing the exclusion list in the top directory of the directories being copied and opening the command prompt in the directory just above the directory and sub-directories to be copied. (Go here if you don't know how to open the command prompt wherever you want.) The various relative paths will then be simple. If you open the command prompt in the default location, things can get complicated.
6. The structure of the exclusions list is one exclusion string per line. Wildcards are not used and do not work. If you want to exclude all files whose names contain ABC, simply place ABC on one line of the exclusion file. If it is being used together with the switch "/S", the exclusion file will apply to sub-directories as well as the main directory.
7. To exclude a particular sub-directory, place its name in the exclusion file with backward slashes before and after its name, viz., \excluded_directory\
8. Use a text editor to create exclusion files. Do not use Microsoft Word or other word processor unless you are careful to create text files. Use ANSI encoding. When I tried UTF-8 encoding, the file did not work.
Bron: http://commandwindows.com/xcopy.htm