Use exif (libexif tool) instead of MetaCam in name-by-date.sh.
authorW. Trevor King <wking@drexel.edu>
Tue, 1 Feb 2011 17:23:39 +0000 (12:23 -0500)
committerW. Trevor King <wking@drexel.edu>
Tue, 1 Feb 2011 17:23:39 +0000 (12:23 -0500)
posts/name-by-date.mdwn
posts/name-by-date/name-by-date.sh

index dd259b4862c65ed0146c3055c3c3c5865b3cf409..729646d9ca807a8fb93032ac3e331a852153fed6 100644 (file)
@@ -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]]
index 1f3f276fef7903e261aac49f5ec6467b80f87fd3..66de6c5c26413fe330a93e037c0cb1351d27d846 100755 (executable)
 #
 # 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