Added time-guessing for VID_xxxxxxxxx.mp4.
authorFrancois Fleuret <francois@fleuret.org>
Sat, 14 Jul 2012 12:40:17 +0000 (14:40 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Sat, 14 Jul 2012 12:40:17 +0000 (14:40 +0200)
archivepics.sh

index 783effd..a1d3f44 100755 (executable)
@@ -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