I've been using IM for a few trivial things in the past, but I'm now trying to automate a lot of what I do within a set of DOS batch files.
So far, I haven't come across any problems that I haven't been able to solve, but now I've encountered a problem which appears to be so simple, yet it has me stumped, and I just can't find the solution.
Basically I've got a simple FOR loop, and for each file encountered in the input folder I want to do some dynamic stuff related to the dimensions of the file. For example: I want to retrieve the pixel dimensions of each file as it's processed, and then use this information to make some decisions, so I need to assign these values to a couple of DOS shell variables.
(I'm currently testing this with just 2 files of different size. ) The first file (alphabetically) is 640x425 pixels, and the second is 400x266.
Here's the code:
Code: Select all
for /f %%a in ('dir /b %infolder%\*.jpg') do
(
ECHO Processing file: "%%a"
SET width='identify -format "%%[fx:w]" %%a'
SET height='identify -format "%%[fx:h]" %%a'
echo %width% %height%
REM call another batch file here to do more work....
((I want to pass in the width and height as parameters)
REM call dowork.bat .... (commented out for clarity)
....
)
Code: Select all
Processing file: "_DSC7795.JPG"
400 266
Processing file: "_DSC7796Copy.JPG"
400 266
Code: Select all
echo "dowork:"
set fred=%infolder%\%imgname%%imgsuffix%
FOR /F %%i IN ('identify -format "%%[fx:w]" %fred%') DO SET width=%%i
echo. %width%
FOR /F %%i IN ('identify -format "%%[fx:h]" %fred%') DO SET height=%%i
echo. %height%
Code: Select all
Processing file: "_DSC7795.JPG"
640 425
dowork:
640
425
Processing file: "_DSC7796Copy.JPG"
400 266
dowork:
400
266
Sorry,... I'm embarrassed to be asking this question because this seems like such a simple issue, but it's got me completely stumped!!!
Maybe there's a better method than using identify to get this information???
Comments welcome... but please, no "use LINUX", use CYGWIN" comments (I have too much invested in these DOS batch files already

Thanks in advance...