Xcopy /exclude does not exclude some of the specified criteria
- by Richard Z.
Good afternoon.
I want xcopy to copy all files meeting a certain criteria located in the C drive to a specific folder, except ones located in the directories specified in excl.txt. The exclusions only work partially - the files located in %systemroot%, %programfiles% and in each profile's appdata are still copied, even though those directories are listed in excl.txt.
How do I make xcopy skip those directories, preferentially still using environment vars to specify the paths?
My current syntax is:
xcopy /s /c /d /h /i /r /y /g /f /EXCLUDE:excl.txt %systemdrive%\*.doc f:\test\
excl.txt currently contains the following:
\%temp%\
\%userprofile%\appdata
\%programfiles%\
\%programfiles(x86)%\
\%systemroot%\
\%programdata%\
appdata
windows
%programfiles%
Thank you very much.