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.
fever_rcaTechnician Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AlexFMCommented:
Assuming that there is only one file meeting the sdat* wildcard, this will work:

dir sdat* /B >> tmp.bat
call tmp.bat
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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
AlexFMCommented:
You can do the same replacing >> with > (overwrite).
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.