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]]
#
# 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