Gulivertx / synology-photos-auto-sort

Script to use exiftool on a Synology NAS or any bash environment to auto sort images from a folder
MIT License
54 stars 16 forks source link

Moving of files with duplicate exif timestamp does not work #8

Closed kaili82 closed 1 year ago

kaili82 commented 3 years ago

Old lines:

Generate a unique ID

                #UUID=$(cat /proc/sys/kernel/random/uuid)
                UUID="U$(date +%s%N)"

                NEW_FILENAME=${FILENAME=//:}_${UUID}.${EXT,,}

                mv -n ${FILE} ${TARGET}/${YEAR}/${YEAR}.${MONTH}/${NEW_NAME}

                let PROGRESS++
                echo -ne "$((${PROGRESS} * 100 / ${TOTAL_FILES_COUNTER}))%\033[0K\r"

                # Remove the moved file from the array
                let FILES_COUNTER--
                FILES_ARR=("${FILES_ARR[@]/$FILE}")

The move command mv in line 247 does not use the modified filename (NEW_FILENAME) but the duplicate filename NEW_NAME. Because the file name NEW_NAME already exists, mv does not do anything. Additional issue: the filename NEW_FILENAME is the old filename instead of the modified one. Therefore, I propose the following modifications:

                # Generate a unique ID
                #UUID=$(cat /proc/sys/kernel/random/uuid)
                UUID="U$(date +%s%N)"
                NEW_NAME=${DATE//:}_${TIME//:}_${UUID}.${EXT,,}

                mv -n ${FILE} ${TARGET}/${YEAR}/${YEAR}.${MONTH}/${NEW_NAME}

                let PROGRESS++
                echo -ne "$((${PROGRESS} * 100 / ${TOTAL_FILES_COUNTER}))%\033[0K\r"

                # Remove the moved file from the array
                let FILES_COUNTER--
                FILES_ARR=("${FILES_ARR[@]/$FILE}")
Gulivertx commented 3 years ago

Thanks for your report. Correct there is an error. Could you do a pull request with the modification?

Gulivertx commented 1 year ago

No fixed with last commit, thank's for report.