Page 1 of 1

batches excluding multiple directory in xcopy

Posted: 31 Dec 2011 03:29
by programchen
my exclude.tmp is as follows:

C:\WINDOWS;c:\Program files

but when i try batch:
echo %windir%;c:\Program files>exclude.tmp

for %%a in (xls ppt ) do (
xcopy "*.%%a" "%destination%" /c /s /exclude:exclude.tmp
)

system still copy files from "program files" directory to destination, what should i do?

Re: batches excluding multiple directory in xcopy

Posted: 31 Dec 2011 07:31
by aGerman
xcopy /?

Code: Select all

  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.

The 2nd sentence tells you why.

Regards
aGerman