New script to add the directory name as an exif tag to images

This commit is contained in:
Jeremy Gardais 2016-10-05 16:47:45 +02:00
parent 56371523de
commit f2a106ee04
1 changed files with 21 additions and 0 deletions

21
tag_photo.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
PICTURE_DIR="${1}"
# New tag to add to the picture
NEW_TAG="description"
# Temp file to store the list of directories
TMP_LIST_DIR="/tmp/list_dir_to_tag"
# List directories
find "${PICTURE_DIR}" -mindepth 1 -type d > "${TMP_LIST_DIR}"
while IFS= read -r DIR
do
TAG_VALUE=$(basename "${DIR}")
printf '%s\n' "Add the tag '${TAG_VALUE}' to all images in ${DIR}"
# Add exif tag to all images of the current directory (not subdir)
find "${DIR}" -iregex '.*\.\(jpg\|gif\|png\|jpeg\)$' -maxdepth 1 -exec exiftool -overwrite_original -P -"${NEW_TAG}"="${TAG_VALUE}" {} \;
done < "${TMP_LIST_DIR}"
exit 0