Computing.Net > Forums > Programming > Getting a file name into a variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Getting a file name into a variable

Reply to Message Icon

Name: Tony D
Date: November 7, 2008 at 07:17:52 Pacific
OS: XP
CPU/Ram: several
Product: Dell
Comment:

Hi,

I am trying to create a batch file that searches a directory for a particular file and then uses the exact name of that file as a variable used as an input for another program. For example, below is a two-line snippet of the batch file:

set filename="UDC3500_FLASHK8V4F.abs.s19"
sreccvt -b 16 0x30 32 -ob -o PPC_3500.s19 %filename%

This makes the file name "UDC3500_FLASHK8V4F.abs.s19" into a variable which is then used as the input to the sreccvt program. Now, the above snippet works fine for the specific file "UDC3500_FLASHK8V4F.abs.s19" but what I would like to do is search the directory for any file of the form "UDC3500*.abs.s19" <note wildcard> and then put the exact name of the found file into the "filename" variable.

The directory will only contain a single "UDC3500" file.

Thank you for your time.



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: November 7, 2008 at 07:33:25 Pacific
Reply:

for %%f in (UDC3500*.abs.s19) do set filename=%%f


0

Response Number 2
Name: Tony D
Date: November 7, 2008 at 07:36:58 Pacific
Reply:

Thanks much, that worked fine.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Getting a file name into a variable

Inserting File name into mult. file www.computing.net/answers/programming/inserting-file-name-into-mult-file/17159.html

Reading another file's size as a variable www.computing.net/answers/programming/reading-another-files-size-as-a-variable/20206.html

Extract file name from file path www.computing.net/answers/programming/extract-file-name-from-file-path/16973.html