allow to breakdown per month only

This commit is contained in:
Guillaume Castagnino 2021-06-01 13:17:13 +02:00
parent 5ee10da858
commit 01b7f57aee
1 changed files with 19 additions and 4 deletions

View File

@ -13,6 +13,7 @@ DELETE=0
DEBUG=0
YES=0
NO_JPEG=0
MONTH_ONLY=0
import_photo()
{
@ -80,9 +81,15 @@ import_photo()
# prepare dir name
local dir
dir=$((exiftool -q -d "%Y/%Y-%m-%d" -if '($datetimeoriginal and ($datetimeoriginal ne "0000:00:00 00:00:00"))' -datetimeoriginal -s3 "${image}" 2>/dev/null ; \
exiftool -q -d "%Y/%Y-%m-%d" -if '($createdate and ($createdate ne "0000:00:00 00:00:00"))' -createdate -s3 "${image}" 2>/dev/null ; \
exiftool -q -d "%Y/%Y-%m-%d" -filemodifydate -s3 "${image}" 2>/dev/null) | head -n 1)
local pattern
pattern="%Y/%Y-%m-%d"
if [ ${MONTH_ONLY} -eq 1 ]
then
pattern="%Y/%Y-%m"
fi
dir=$((exiftool -q -d "${pattern}" -if '($datetimeoriginal and ($datetimeoriginal ne "0000:00:00 00:00:00"))' -datetimeoriginal -s3 "${image}" 2>/dev/null ; \
exiftool -q -d "${pattern}" -if '($createdate and ($createdate ne "0000:00:00 00:00:00"))' -createdate -s3 "${image}" 2>/dev/null ; \
exiftool -q -d "${pattern}" -filemodifydate -s3 "${image}" 2>/dev/null) | head -n 1)
if [ "x${title}" != "x" ]
then
dir="${dir} - ${title}"
@ -124,13 +131,14 @@ import_photo()
}
while getopts "hdjn:y" flag
while getopts "hdjmn:y" flag
do
case $flag in
h)
echo "Usage: $0 [options] <file|directory>..."
echo "-d : delete source"
echo "-j : RAW+jpeg, skip jpeg"
echo "-m : breakdown by month"
echo "-n <name> : title"
echo "-y : force-yes"
exit
@ -141,6 +149,9 @@ do
j)
NO_JPEG=1
;;
m)
MONTH_ONLY=1
;;
n)
TITLE=${OPTARG}
case ${TITLE} in
@ -171,6 +182,10 @@ if [ ${DELETE} -eq 1 ]
then
echo "--- Deletion of source image enabled ---"
fi
if [ ${MONTH_ONLY} -eq 1 ]
then
echo "--- Image breakdown per month only ---"
fi
if [ ${YES} -ne 1 ]
then
read -p "Proceed? [Y/n] "