#!/bin/sh # Grabs latitude and longitude values from stdin and stores # them in all JPGs in current directory. # The two values have to be separated by a comma. # IFS="," read lat long # If sign is negative, we have to change reference latRef="N"; latSign=$(echo $lat | cut -c 1) if [ "X$latSign" = "X-" ] then # Delete minus from beginning lat=$(echo $lat | sed s/^-//) latRef="S" fi lonRef="E"; lonSign=$(echo $long | cut -c 1) if [ "X$lonSign" = "X-" ] then long=$(echo $long | sed s/^-//) lonRef="W" fi # Calculate latitude/longitude degrees and minutes latDeg=$( echo "scale=0; $lat/1" | bc ) latMin=$( echo "scale=2; m=($lat-$latDeg) *100/ 0.016666;scale=0;m/1" | bc ) lonDeg=$( echo "scale=0; $long/1" | bc ) lonMin=$( echo "scale=2; m=($long-$lonDeg)*100/0.016666;scale=0;m/1" | bc ) echo Picture location will be: $latDeg $latMin\' $latRef , $lonDeg $lonMin\' $lonRef for fil in *.jpg # Also try *.JPG do echo Updating $fil .... exiv2 -M"set Exif.GPSInfo.GPSLatitude $latDeg/1 $latMin/100 0/1" \ -M"set Exif.GPSInfo.GPSLatitudeRef $latRef" \ -M"set Exif.GPSInfo.GPSLongitude $lonDeg/1 $lonMin/100 0/1" \ -M"set Exif.GPSInfo.GPSLongitudeRef $lonRef" \ $fil done