Browse Source

allow to breakdown per month only

master
Guillaume Castagnino 8 months ago
parent
commit
01b7f57aee
  1. 23
      photos/import.sh

23
photos/import.sh

@ -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] "

Loading…
Cancel
Save