From 4239b7a439088566deb0ac0c1ba0f0984a431064 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 18 Feb 2019 03:29:36 +0300 Subject: [PATCH] fixed an issue with copying overflowing filenames... Signed-off-by: Alex A. Naanou --- scripts/process-archive.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/process-archive.sh b/scripts/process-archive.sh index 2f8fa99e..58dfff42 100755 --- a/scripts/process-archive.sh +++ b/scripts/process-archive.sh @@ -236,8 +236,23 @@ if [ -z $SKIP_PREVIEWS ] ; then fi - # collect previews to one location... +jpg2dir(){ + FROM=$1 + TO=$2 + + FULL_TO=$2/`basename "$FROM"` + I=0 + + while [ -e $FULL_TO ] ; do + I=$((I + 1)) + FULL_TO=$2/`basename -s .jpg "$FROM"`_${I}.jpg + done + + cp -rl "$FROM" "$FULL_TO" +} +export -f jpg2dir + # XXX test!!! if ! [ -z "$COMMON_PREVIEWS" ] ; then if ! [ -e "./$COMMON_PREVIEWS" ] ; then @@ -246,10 +261,12 @@ if ! [ -z "$COMMON_PREVIEWS" ] ; then #if [ -z $TOTAL ] ; then # export TOTAL=`find . -path '*hi-res (RAW)/*.jpg' | wc -l` #fi + # XXX BUG: this does not rename if target exists... find . -type d \ -name 'preview (RAW)' \ -print \ - -exec cp -rl "{}" "./$COMMON_PREVIEWS" \; + -exec bash -c 'jpg2dir "{}" "./$COMMON_PREVIEWS"' \; + #-exec cp -rl "{}" "./$COMMON_PREVIEWS" \; #-exec rm -rf "./$d" fi