2011
10.03

When sharing digital images online, I often find myself looking for an easy way to copy and paste the EXIF data. This little script when put into my ~/.gnome2/nautilus-scripts folder will create a text file of the most commonly used EXIF information.

#!/bin/bash
files=$#
count=1
message=`echo "Dumping EXIF from $files files"`

(while [ $# -gt 0 ]; do

	# Strip off the file extension, including the "."
	upperExt=`echo $1 | sed 's/.*\(\..*\)/\1/' | tr '[a-z]' '[A-Z]'`

	if [ -f "$1" ]
	then
		# Get the file name without the extension
		# trimmed=`echo $1 | sed 's/\(.*\)\..*/\1/'`

		if [ $upperExt = ".JPG" -o  $upperExt = ".JPEG" -o  $upperExt = ".PPM" -o $upperExt = ".CR2" -o $upperExt = ".NEF" -o $upperExt = ".OTHER_RAW_EXTENSION" ]
		then
			# Output EXIF data to a new text file named the same as the original image.
			exiftool -canon -S "$1" > "$1.txt"
		fi
	fi
	# Output the zenity progress bar
	sav=`echo "(($count / $files) * 100)" | bc -l`
	echo $sav
	count=`expr $count + 1`
shift
done) | zenity --progress --auto-close --auto-kill --text "$message"