fcbc
asked on
use variable file name in directory and process that file in batch command
I want to look at a directory and process (print) the random TIFF files that appear. The problem is that names are not uniform, they could be just about anything in a tiff extension.
So how do I parse the contents of a directory into a variable and process that variable? There may be more than one TIFF file waiting to be processed, I can loop it until there is nothing else to process.
I would be using the
rundll32.exe C:\WINDOWS\System32\shimgv w.dll,Imag eView_Prin tTo /pt "c:\faxes\faxmessage.tiff" "\\corporate\printername" "" ""
comamnd to print the tiff files.
Thanks,
Chuck
So how do I parse the contents of a directory into a variable and process that variable? There may be more than one TIFF file waiting to be processed, I can loop it until there is nothing else to process.
I would be using the
rundll32.exe C:\WINDOWS\System32\shimgv
comamnd to print the tiff files.
Thanks,
Chuck
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
wow - WORKS FANTASTIC.
If anyone else tries this, just have a minor correction to above:
rundll32.exe C:\WINDOWS\System32\shimgv w.dll,Imag eView_Prin tTo /pt "%%~fa" "" ""
you will need those extra 2 sets of quotes at the end of the line.
Thank you for your quick response!
If anyone else tries this, just have a minor correction to above:
rundll32.exe C:\WINDOWS\System32\shimgv
you will need those extra 2 sets of quotes at the end of the line.
Thank you for your quick response!
no problem for is very powerful command and used a lot around here... for /? set /? has lots of useful stuff, or ask here if needed.
stevev
stevev
@echo off
cd /d C:\faxes
for %%a in (*.tif?) do (
rundll32.exe C:\WINDOWS\System32\shimgv
echo Do something else with the file "%%~a", full name is "%%~fa"
)
or read a directory listing such as
@echo off
for /f %%a in ('dir /b /a-d *.tif?') do (
echo Filename is %%~a
)
I presume you might want to do a move command after the print too?
The %%a is abritary and case sensitive, use %%T or %%t or whatever if you prefer.
the ~ means remove any " " around the filename, in case it has spaces etc. it is better to remove then add yourself.
You can add qualifiers to the %%~a to get (f = full filename, n=name, x=extension etc.)
for /? explains more.
Steve