If you're looking for a pure bash implementation, ImageMagick's convert command is what you're looking for:

for szFile in /path/*.png
do 
    convert "$szFile" -rotate 90 /tmp/"$(basename "$szFile")" ; 
done

Above will leave existing files intact and copy the newly rotated ones to /tmp so you can move or copy them somewhere else or even replace the existing ones after the conversion and after verification.

(and it'll work on all recent releases of Ubuntu as it's standard software)


for file in *.JPG; do convert $file -rotate 90 rotated-$file; done

This will copy-rotate-and-rename your files.

If you want to leave the original files untouched just yet, this method may work well for you...

Note that this is case-sensitive: if your files are named *.jpg replace with lower-case (or *.png ...) accordingly.