|
Answer» How can I put a specific filename into a variable? The line below doesn't pipe the output into the variable %1.
dir *.img /b > %1
I would then use that variable and use it in a third party program.
rem RUN the program with the file name entered-variable isn't working, otherwise ok start c:\tempforconsult\dl32 bank %1 0x40000000
Any HELP is appreciated.There are probably a few ways to do this. %0-%9 are command line variables with read-only properties. The cmd processor assigns them at run time based on user input. However this may work:
Code: [Select] @echo off for /f %%a in ('dir *.img /b') do (set var=%%a) start c:\tempforconsult\dl32 bank %var% 0x40000000
Note: the DIR command used with a wild card will produce a collection of file names and VALUE of var may be unpredictable. The code above ASSUMES there is only one IMG file in the directory.
Also note: < is the symbol for redirected input. | is the pipe.
Hope this helps. Thanks for the code and the correction. Works like a charm Hi,
I have the following problem.....i have to create a batch file or any script to automate the following...
I need to put the filenames in a directory into a variable and pass them one by one to a third party program.....
the thing is that i am not sure how many files are there... and the filenamess are also dynamic....
the problem is that the third party program doesn't accept wildcards.....so how can i pass some .dat files to the third party program for processing...
so if anyone can point me on how to go about this...then i will be really grateful....
Thanks, Regards. Won't the above loop serve your purpose too.
|