Search code examples
windowsbatch-filecommanddosxcopy

How to create an exclude file entry for xcopy that matches the extension of a file name?


Consider the following batch statements:

for / %f in (C:\temp\cool\*) do if not "%~nf" == "update" 
    xcopy /r /Y /S /D:01-01-2001 /EXCLUDE:excl.txt %f c:\temp\%~nf\

It uses an file with a list of excludes. This excl.txt looks like:

.config
.log

It is supposed to skip all files log and config files. Unfortunately it is also skipping this file:

cfw.loginpopup.js

How can I fix this problem? I only like to exclude files that end in a .log.


Solution

  • Maybe I'm thinking too simple, but you can try this for the exclusion list:

    *.config 
    *.log