Hi James,
File extension is a Windows kind of thing. convert and mogrify - as other ImageMagick tools - read the magic number to determine the format of the input file. test was a text file intended to demonstrate that this script doesn’t check the input format (neither did my example). If you wanted to check the input format in order for your script to handle only supported graphic formats and ignore the others (avoiding errors), I would suggest replacing this line
-f "$a" ] && echo mogrify -format $TYPE $a || continue
with those lines
if -f "$a" ] ; then
file "$a" | grep -q -i -e JPG -e JPEG -e PNG -e pixmap -e PDF -e GIF || continue
mogrify -format $TYPE $a || continue
fi
Notice that JPG, JPEG, PNG, etc don’t refer to file extensions. These strings are just part of the output of the command file applied to each argument. You can complete this list with other strings when you know the ouptut of file for other graphics formats (like Windows bitmaps or tiff for example).