Thanks for the reply. You are correct, that was one thing I missed, passing the file name to the identify -format command. However, I think I still have many other problems with my code. It seems maybe I still don't fully understand how some of these commands work. I was using the FOR loop with the identify command as if the %%i being passed was the filename, but after reading through the IM windows usage wiki again I think the FOR loop examples they used where they passed a command in the IN statement was not traversing a set of files and passing those file names to the identify command, but were traversing a set of identify commands. For example,
Code: Select all
FOR /F %%L IN ('identify -format "Width=%%w\nHeight=%%h" %1') DO set %%L
loops through the identify -format command first with width, %1 pulls a fully qualified path name from somewhere (but from where?) and passes it to the identify width's value and set's it to %%L, then the FOR loop continues to height, which is then again set to %%L. Am I understanding that right now? If so, then my original code is all wrong.
I revised my code but now I don't know what's going wrong. I really dislike DOS prompt. Maybe if someone would be so kind as to write their own version of code that does what I'm trying to achieve. It seems like it would be so easy for someone who actually understands the syntax for DOS and IM. The logic is dead simple, it's just getting the syntax right that's kicking my @$$.
Code: Select all
@echo off
cd c:\images
FOR %%i IN ("*.jpg") DO (
echo %%i
set width=identify -format "%w" %%i
echo %width%
set height=identify -format "%h" %%i
echo %height%
IF %width% gtr %height% (
echo "w is bigger")
echo "h is greater"
)
I wrote that just to see if what I'm doing is right, but something is really wrong. The output tells me "-format was unexpected at this time." What the hell? If I only set width, leaving out anything related to height I get:
c:\images>canvasize.bat
RFM.JPG
identify -format "%w" TC2.JPG
indentify -format "i
SMT.JPG
identify -format "%w" TC2.JPG
indentify -format "i
TC2.JPG
identify -format "%w" TC2.JPG
indentify -format "i
This just doesn't make any sense to me. Maybe there is somebody that would be so kind as to just write their own version of code that does what I need? The logic is dead simple, but syntax is what's holding me back...