User:Tomwm/Rotate right
From RHLUG
File: ~/.gnome2/nautilus-scripts/Rotate right
#!/bin/sh
for arg; do
filetype=`file -i "$arg"`
temp="~$arg.rotate-left"
if [ -n "`echo $filetype | grep -i 'jpeg' `" ]; then
if jpegtran -rotate 90 "$arg" > "$temp"; then
# Removing the original first makes it work on sshfs mounts
rm "$arg"
fi
mv "$temp" "$arg"
else
convert -rotate 90 "$arg" "$arg"
fi
done
# Clear the thumbnails of rotated images
python - <<EOF
# Roughly based on http://ifireball.wordpress.com/sources/delete_thumbnailspy/, but with less
# algorithmic stupidity
import os
from hashlib import md5
thumb_names = set(md5(url) + '.png' for url in os.environ['NAUTILUS_SCRIPT_SELECTED_URLS'].splitlines())
thumb_dir = os.path.expanduser('~/.thumbnails')
for root, dirs, files in os.walk(thumb_dir):
for f in files:
if f in thumb_names:
os.remove(os.path.join(root, f))
EOF

