X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=archivepics.sh;h=a1d3f44df1c2184be3abd14ec920df2846b36c94;hb=e2f53975cc8e22c351a9b8095f88320cc1c40db2;hp=d6a1742d442dd17f2bb7ae8c87aa65b8133354a4;hpb=9fcf8afdc215faca5b95075189e582a9d8581942;p=scripts.git diff --git a/archivepics.sh b/archivepics.sh index d6a1742..a1d3f44 100755 --- a/archivepics.sh +++ b/archivepics.sh @@ -34,6 +34,8 @@ # exit 0 # fi +MONTHS=("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec") + export ARCHIVED_PICS="$@" set -e @@ -72,6 +74,8 @@ for i in "$@"; do if [[ -f ${ref} ]]; then + echo "Checking ${ref} date" + TAG=$(exif --ifd=EXIF -t "Date and Time (original)" "${ref}" | grep Value) if [[ ${TAG} ]]; then @@ -84,7 +88,14 @@ for i in "$@"; do else - echo "Can not find a reference picture file for $i, can not set the date properly." + 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/")) + + if [[ "${timestamp}" ]]; then + echo "Setting time of $i to ${timestamp}" + touch -t ${timestamp} "$i" + else + echo "Can not guess date for $i." + fi fi @@ -93,6 +104,8 @@ done # Moving the file to the proper archive directory, which is created # first when needed +LOG_ARCHIVING=archive_$(date +%Y_%m_%d_%H:%M:%S).log + for i in "$@"; do ARCHIVING_PATH=$(ls -l --time-style=+%Y/%b --format=verbose "$i" | awk '{ print $6 }') @@ -101,6 +114,7 @@ for i in "$@"; do echo "Archiving ${IMAGE_ARCHIVE_DIR}/${ARCHIVING_PATH}/"$(basename "$i") - cp -p -i "$i" ${IMAGE_ARCHIVE_DIR}/${ARCHIVING_PATH} + cp -p -i "$i" ${IMAGE_ARCHIVE_DIR}/${ARCHIVING_PATH} && \ + echo "$i -> ${IMAGE_ARCHIVE_DIR}/${ARCHIVING_PATH}" >> ${LOG_ARCHIVING} done