From: Francois Fleuret Date: Sat, 14 Jul 2012 12:40:17 +0000 (+0200) Subject: Added time-guessing for VID_xxxxxxxxx.mp4. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2f53975cc8e22c351a9b8095f88320cc1c40db2;p=scripts.git Added time-guessing for VID_xxxxxxxxx.mp4. --- diff --git a/archivepics.sh b/archivepics.sh index 783effd..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 @@ -86,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 @@ -95,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 }') @@ -103,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