• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 743
  • Last Modified:

Execute a file with a wildcard name in a DOS batch file?

Hope I phrased that question correctly...  I have a file I execute weekly to update several computers.  The file name is always "sdatxxx.exe", where the xxxx is a number.  The number may be more than 4 digits in the future.

I would like to make a batch file I can execute to save several steps.  I can make all the commands, except for the file name.  How can I specify the file name using wildcards?  I tried "sdat****.exe", and that didn't cut it.  That's about the extent of my batch wildcard knowledge!  :-)

So can I use a batch file to execute a file, when the file name changes regularly?  If it makes a difference, I will be executing this file off a CD, and the file will be the only file on the CD.
0
fever_rca
Asked:
fever_rca
  • 3
  • 2
1 Solution
 
AlexFMCommented:
Assuming that there is only one file meeting the sdat* wildcard, this will work:

dir sdat* /B >> tmp.bat
call tmp.bat
0
 
fever_rcaTechnician Author Commented:
I didn't explain enough, AlexFM.  I'm trying to execute the file from a CD, which is the D: drive.  With your bat file, it doesn't find the file because it's looking for the file on the C: drive.  The bat file will have to reside on the C: drive of the computers getting updated.

Is there a way to execute the sdat file when it's on the D: drive and the bat file is on the C: drive?

Thanks,
Richard
0
 
AlexFMCommented:
This is just an idea, you can make change according to your needs, for example:

dir D:\sdat* /B >> tmp.bat
D:
CD \
call tmp.bat
0
 
fever_rcaTechnician Author Commented:
Cool, I worked it out pretty much like what you suggested.  Here's what worked for me:

del c:\tmp.bat
dir d:\sdat* /B >> C:\tmp.bat
d:
call c:\tmp.bat

I had to put the delete command first.  That's for the next time the batch file is ran, because there's all ready a "tmp.bat" file with a sdat****.exe listed in it.  Otherwise the multiple sdat listing causes the command to endlessly list the file name down the screen.

Thanks for your prompt results!  

Richard
0
 
AlexFMCommented:
You can do the same replacing >> with > (overwrite).
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.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now