Rotating Images with BASH and ImageMagick, take 2

In my last post, I rotated 12 images with non-contiguous filenames like 91, 115, 185. This time, though, I have a set of images with contiguous filenames so I don’t need to type each one in by hand.

I rotated the images with ImageMagick version 6 in Cygwin’s BASH Shell using 1 line of code.

For each number, or integer (i), starting at 104 up through and including 112 create a string for the filename using that number zero-padded to 4 digits. This filename is used with ImageMagick to rotate the image 90 degrees counter-clockwise and if the image was successfully rotated the filename is printed to standard output with this information.

$ for i in {104..112}; do filename=$(printf "CRLA_1984-07_5329_%04d.tif" "$i"); mogrify -rotate -90 "$filename" && echo "$filename ROTATED 90 CCW"; done

Jeremy Moore

jeremy.moore@txstate.edu