From: W. Trevor King Date: Tue, 1 Feb 2011 17:23:39 +0000 (-0500) Subject: Use exif (libexif tool) instead of MetaCam in name-by-date.sh. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2317ba004cfcfaefeadb872c40a4742867a39836;p=mw2txt.git Use exif (libexif tool) instead of MetaCam in name-by-date.sh. --- diff --git a/posts/name-by-date.mdwn b/posts/name-by-date.mdwn index dd259b4..729646d 100644 --- a/posts/name-by-date.mdwn +++ b/posts/name-by-date.mdwn @@ -6,11 +6,11 @@ creation date. DSC_0356.JPG taken on "2010.07.02.08.38.10" ... -`name-by-date.sh` uses Daniel Stephens' [MetaCam][] (ebuild in my -[[Gentoo overlay]]) to extract thed ate from the picture's metadata, -so you'll have to install that first. +`name-by-date.sh` uses the `exif` command line interface to +[libexif][] to extract the date from the picture's metadata, so you'll +have to install that first. -[metacam]: http://www.cheeseplant.org/~daniel/pages/metacam.html +[libexif]: http://libexif.sourceforge.net/ [[!tag tags/bash]] [[!tag tags/programming]] diff --git a/posts/name-by-date/name-by-date.sh b/posts/name-by-date/name-by-date.sh index 1f3f276..66de6c5 100755 --- a/posts/name-by-date/name-by-date.sh +++ b/posts/name-by-date/name-by-date.sh @@ -21,15 +21,15 @@ # # usage: name-by-date.sh $(find . -name '*.jpg') # -# uses metacam, [, cut, dirname, echo, file, grep, let, mv, and sed. +# uses exif, [, cut, dirname, echo, file, grep, let, mv, and sed. while [ -n "$1" ]; do FILE=$1 TYPE=$(file "$FILE" | grep JPEG) if [ -n "$TYPE" ]; then - DATE_LINE=$(metacam "$FILE" | grep 'Image Creation Date') - DATE=$(echo "$DATE_LINE" | cut -d: -f 2,3,4,5,6 | sed 's/:/./g' | cut -d\ -f2,3 | sed 's/ /./g') + ASCII_DATE=$(exif -m -t 'Date and Time' "$FILE") # 2010:07:02 08:36:20 + DATE=$(echo "$ASCII_DATE" | sed 's/:/./g' | sed 's/ /./g') if [ -z "$DATE" ]; then echo "$FILE has no stored date" else