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
w_wagnerAsked:
Who is Participating?
 
Bill PrewCommented:
Here's an example of the BAT script approach I was suggesting.

@echo off
if exist "%TEMP%\_exclude_.txt" del "%TEMP%\_exclude_.txt"
for /D %%A in ("c:\temp\inetpub\wwwroot\*") do if exist "%%~A\subdir\" echo %%~A\subdir\>>"%TEMP%\_exclude_.txt"
xcopy C:\temp D:\dest /E /EXCLUDE:"%TEMP%\_exclude_.txt"

Open in new window

~bp
0
 
Bill PrewCommented:
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
0
 
kevinhiggCommented:
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!
0
 
w_wagnerAuthor Commented:
Thanks. I'll give your suggetions a try.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.