ImageMagick: Rotate a batch of images using convert and a for loop

 
# rotate an image
convert image1.png -rotate "-90" rotate_image1.png


# rotate an image, and save it on another folder
convert image1.png -rotate "-90" new_folder/rotate_image1.png


# rotate a batch of images, and save rotated files as new files
for file in *.png; do convert $file -rotate "-90" "rotate_$file"; done


# rotate a batch of images, and save rotated files on another folder
for file in *.png; do convert $file -rotate "-90" "new_folder/rotate_$file"; done


# same as above, but if the file names contain spaces
for file in *.png; do convert "$file" -rotate "-90" "new_folder/rotate_$file"; done


# rotate a batch of images named "crop_image01.jpg, crop_image02.jpg, etc" and 
# save them with the names "rotate_image01.jpg, rotate_image02.jpg, etc"
for file in crop_*.jpg
do
  convert "$file" -rotate "-90" "$(echo "$file" | sed -e 's/crop_/rotate_/' - )" 
done

 

Related Snippets

•  ImageMagick: Rotate a batch of images using convert and the find command
•  ImageMagick: Resize a batch of images using convert and a for loop
•  ImageMagick: Resize a batch of images using convert and the find command
•  ImageMagick: Crop a batch of images using convert and the find command
•  ImageMagick: Crop a batch of images using convert and a for loop