X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=scripts.git;a=blobdiff_plain;f=archivepics.sh;h=9c608c129b73f75cba38c144dff72281fef0c2ab;hp=a1d3f44df1c2184be3abd14ec920df2846b36c94;hb=0c7aaabde9bf206dd017f468bf5af86e2efb22dd;hpb=5d2e211f0e3dbd1b497b41f4f0c2524eeb9aed32 diff --git a/archivepics.sh b/archivepics.sh index a1d3f44..9c608c1 100755 --- a/archivepics.sh +++ b/archivepics.sh @@ -76,16 +76,25 @@ for i in "$@"; do echo "Checking ${ref} date" - TAG=$(exif --ifd=EXIF -t "Date and Time (original)" "${ref}" | grep Value) + TAG_VALUE=$(exiv2 -P nv "${ref}" 2>/dev/null | grep ^DateTimeOriginal | \ + sed -e "s/^[^ ]* *\([0-9]*\):\([0-9]*\):\([0-9]*\) *\([0-9]*\):\([0-9]*\):\([0-9]*\).*$/\1\2\3\4\5.\6/") - if [[ ${TAG} ]]; then - TIMESTAMP=$(echo ${TAG} | sed -e \ - "s/^ *Value: *\([0-9]*\):\([0-9]*\):\([0-9]*\) *\([0-9]*\):\([0-9]*\):\([0-9]*\).*$/\1\2\3\4\5.\6/") - touch -t $TIMESTAMP "$i" + if [[ "${TAG_VALUE}" ]]; then + touch -t ${TAG_VALUE} "$i" else echo "No exif tag in $i, can not set the date properly." fi + # TAG=$(exif --ifd=EXIF -t "Date and Time (original)" "${ref}" | grep Value) + + # if [[ ${TAG} ]]; then + # TIMESTAMP=$(echo ${TAG} | sed -e \ + # "s/^ *Value: *\([0-9]*\):\([0-9]*\):\([0-9]*\) *\([0-9]*\):\([0-9]*\):\([0-9]*\).*$/\1\2\3\4\5.\6/") + # touch -t $TIMESTAMP "$i" + # else + # echo "No exif tag in $i, can not set the date properly." + # fi + else timestamp=($(basename $i | sed -e "s/^VID_\([0-9][0-9][0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)_\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\).*$/\1\2\3\4\5.\6/"))