Link to home
Start Free TrialLog in
Avatar of w_wagner
w_wagner

asked on

DOS Wildcard for directory

I am looking for the proper syntax to use so that the xcopy command will skip over the * directory as it can have different names. Like:

XCOPY C:\temp /E /EXCLUDE:\inetpub\wwwroot\*\subdir
Avatar of Bill Prew
Bill Prew

Well, a couple of issues with that. First the /EXCLUDE option actually wants the name of a text file, and in the text file each line contains a string that if it matches any part of the file being copied it will be skipped.  But wildcards are not allowed in this exclude text file.

What you could do is do a few commands in a BAT file before the XCOPY that would build the text file of all folders that matched the template you posted above.  It can't be done with a simple wildcard like you tried, they aren't allowed in the middle of a path like that, but with a few more commands we could build the list of the directories you want to exclude.  Could that work for you, a BAT file?

~bp
Are you trying to explicitly exclude the "subdir" one level deep from wwwroot?  Is the "subdir" name somewhat unique?  I believe that the /exclude param of xcopy expects a file that contains patterns to match; from the help:

/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.

So you may want to use something like \subdir\ if that would be unique.  It also looks like you're missing the param to specify where you're copying C:\temp to?  Best of luck!
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of w_wagner

ASKER

Thanks. I'll give your suggetions a try.