X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=archivepics.sh;h=202d73c57dfcc176add80f7ed2dbb089e3cfabcb;hb=32ea9d8fc8d68b70199f8eb21a7affa82caaccf3;hp=d96db4e9f068fadd13bcf11eb7b99e7c965498da;hpb=2b983c5c7336826b764036e3e1478a5a8159248a;p=scripts.git diff --git a/archivepics.sh b/archivepics.sh index d96db4e..202d73c 100755 --- a/archivepics.sh +++ b/archivepics.sh @@ -24,14 +24,14 @@ # accompanying JPG for the MOV) # (3) Move the JPG and MOV to an archive directory of the form -# ${GP_ARCHIVE_DIR}/year/month, create the directory when necessary. +# ${IMAGE_ARCHIVE_DIR}/year/month, create the directory when necessary. [[ ${archive_size_min} ]] || archive_size_min=1048576 # 1Mb set -e -if [[ ! ${GP_ARCHIVE_DIR} ]]; then - echo "You have to set \$GP_ARCHIVE_DIR" >&2 +if [[ ! ${IMAGE_ARCHIVE_DIR} ]]; then + echo "You have to set \$IMAGE_ARCHIVE_DIR" >&2 exit 1 fi @@ -39,7 +39,7 @@ fi for i in "$@"; do - if [[ ! -f ${i/JPG/MOV} ]]; then + if [[ ! -f ${i/JPG/MOV} ]] && [[ ! -f ${i/JPG/3gp} ]]; then if [[ $(stat --printf=%s $i) -lt ${archive_size_min} ]]; then echo "Image $i is too small." @@ -54,7 +54,13 @@ done for i in "$@"; do - ref=${i/MOV/JPG} + base=${i/%.???/} + + if [[ -f ${base}.JPG ]]; then ref=${base}.JPG; fi + if [[ -f ${base}.jpg ]]; then ref=${base}.jpg; fi + if [[ -f ${base}.jpeg ]]; then ref=${base}.jpeg; fi + + echo "ref=${ref}" if [[ -f ${ref} ]]; then @@ -83,10 +89,10 @@ for i in "$@"; do ARCHIVING_PATH=$(ls -l --time-style=+%Y/%b --format=verbose $i | awk '{ print $6 }') - mkdir -p ${GP_ARCHIVE_DIR}/${ARCHIVING_PATH} + mkdir -p ${IMAGE_ARCHIVE_DIR}/${ARCHIVING_PATH} - echo "Archiving ${GP_ARCHIVE_DIR}/${ARCHIVING_PATH}/$(basename $i)" + echo "Archiving ${IMAGE_ARCHIVE_DIR}/${ARCHIVING_PATH}/$(basename $i)" - cp -p -i $i ${GP_ARCHIVE_DIR}/${ARCHIVING_PATH} + cp -p -i $i ${IMAGE_ARCHIVE_DIR}/${ARCHIVING_PATH} done