Page 1 of 1

"Mogrify" error handling in Windows batch

Posted: 2017-02-14T01:28:36-07:00
by wallywalters
I'm writing a Windows batch file to change folders full of TIF files to JPG and want it to go to an error-handling label if the TIF file is invalid. The relevant code is essentially

Code: Select all

  mogrify.exe -format jpg "%1"    
  if not %ERRORLEVEL%==0 goto :BAD_FILE 
but even when I run it on test TIFs designed to fail the test, it returns an errorlevel of 0, so I can't brandh to the error reporting subroutine. How can I make Mogrify return proper error codes? Thanks.

Re: "Mogrify" error handling in Windows batch

Posted: 2017-02-14T01:33:47-07:00
by snibgo
wallywalters wrote:if not %ERRORLEVEL%==0
That's not how to do it. I suggest you read up on Windows BAT scripts. Try:

Code: Select all

if ERRORLEVEL 1