doscode wrote:Hello,
I am using Windows XP and batch file where I have this command:
Code: Select all
convert map2.png -format "%%wx%%h" info:
after executing it I see this: 256x158 and I need to save it to variable and then to
paste content of the variable to next command:
result.png -resize ...here to put the content of the variable...
I have no idea how can I get the result to variable. Is it possible to do it in single batch file?
Your idea is not clear for me.
Are
%%w & %%h for parameters or are
common variables?
The sintax %%var is used only with
for parameters in batch context (they are %var in commandline context).
If they are common variables they should be
%w%x%h%But, if I understand and the first command works for you, this may help
Code: Select all
rem if w & h are for parameters use
for /f "usebackq tokens=*" %%i in (`convert map2.png -format "%%wx%%h" info:`) do (
for /f "usebackq tokens=*" %%n in (`convert result.png -resize %%i`) do (
echo Output is %%n
)
)
rem if w & h are standard variables use
for /f "usebackq tokens=*" %%i in (`convert map2.png -format "%w%x%h%" info:`) do (
for /f "usebackq tokens=*" %%n in (`convert result.png -resize %%i`) do (
echo Output is %%n
)
)
%%i holds output of the first
for command, and can be used by the second.
Also, you may split 256x158,
Code: Select all
for /f "usebackq tokens=1,2 delims=x" %%i in (`convert map2.png -format "%%wx%%h" info:`) do (
rem if output is 256x158, now %%i=256 and %%j=158
for /f "usebackq tokens=*" %%n in (`convert result.png -resize %%ix%%j`) do (
echo output is %%n
)
)