# exit 0
# fi
+MONTHS=("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec")
+
export ARCHIVED_PICS="$@"
set -e
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
# 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 }')
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