diff --git a/moveExifDescriptionToCsvAndPlex.sh b/moveExifDescriptionToCsvAndPlex.sh new file mode 100644 index 0000000..92c6318 --- /dev/null +++ b/moveExifDescriptionToCsvAndPlex.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# scan the photo library for a specific year, add the exif-descriptons as title to plex +PHOTOPATH='/media/plex/Photos' +OUTPUT="~/photos.csv" +SQLFILE="/tmp/update_plexdb.sql" + + +function set_file_desc { + image="$*" + filename=$(basename "${image}") + filefirstname="${filename%.*}" + IDESC=$(exiftool -EXIF:ImageDescription "${image}") + IFS=: read -r dummy title <<< "$IDESC" + titleclean=$(echo ${title} | tr ';' ':') + if [[ ${#titleclean} -gt 2 ]]; then + echo "${filefirstname};${titleclean}" >> ${OUTPUT} + fi + +} + +YEAR=$1 + +if [[ ${#YEAR} -gt 3 ]]; then + rm -f ${OUTPUT} + find ${PHOTOPATH}/${YEAR} -type f -iname "*.jpg" -print0 | while IFS= read -r -d '' file; do + echo $file + # set_file_desc $file + done + sed -i "s/'/''/g" ${OUTPUT} +fi + + + +while IFS= read -r line; do + echo "Text read from file: $line" + IFS=';' read -r filename title <<< "$line" + echo "update metadata_items set title='${title}' where metadata_type=13 and title_sort='${filename}';" >>${SQLFILE} +done < ${OUTPUT} + + +systemctl stop plexmediaserver.service +cat ${SQLFILE} | /usr/lib/plexmediaserver/Plex\ SQLite "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" +systemctl start plexmediaserver.service