Skip to content

Instantly share code, notes, and snippets.

@cjreeve
Last active December 14, 2015 08:30
Show Gist options
  • Save cjreeve/bb0dbaaae6ebd50aa5ca to your computer and use it in GitHub Desktop.
Save cjreeve/bb0dbaaae6ebd50aa5ca to your computer and use it in GitHub Desktop.
Copies picasa meta data (region names) to OpenMeta and Windows tags so they are searchable via Spotlight and windows search
#!/bin/bash
usage="
NAME
picasa2tags -- copies Picasa Region Names to OpenMeta and Windows tags
SYNOPSIS
picasa2tags [OPTION] [DIR/FILE]
OPTIONS
-r recursively copy tags for files in directory
-n non recursively copy tags in direcory
-p path to single file to copy tags
"
if [ x$2 = "x" ]; then
echo "$usage"
exit
fi
if [ $1 = "-r" ] ; then
fileList="$(find $2 -name *.[jJ][pP][gG])"
elif [ $1 = "-n" ]; then
fileList="$2/*.[jJ][pP][gG]"
elif [ $1 = "-p" ]; then
fileList=$2
else
echo "$usage"
exit
fi
for file in $fileList; do
regionname=$(exiftool -regionname $file | cut -d : -f2 | sed 's/, / /g') # get names
#regionname=$(exiftool -regionname $file | cut -d : -f2 | sed 's/, /,/g') # handle spaces
read -rd '' regionname <<< "$regionname" # cut preceding space
if [ x$regionname = "x" ]; then # only change photos that have a regionname
echo "unchanged:$file"
else
openmeta -a $regionname -p $file # save to openmeta tags
#openmeta -a "$regionname" -p $file # handle spaces
om2exif.sh -p $file # updates EXIF data using other script
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment