?
Solved

DOS Wildcard for directory

Posted on 2012-08-23
6
Medium Priority
?
410 Views
Last Modified: 2014-05-22
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
0
Comment
Question by:w_wagner
  • 2
4 Comments
 
LVL 59

Expert Comment

by:Bill Prew
ID: 38327710
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
 
LVL 5

Expert Comment

by:kevinhigg
ID: 38327714
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
 
LVL 59

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 38327732
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
 

Author Comment

by:w_wagner
ID: 38328255
Thanks. I'll give your suggetions a try.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question