From f2a106ee049f83bcb492f5e2e89667e8a3b3f628 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 5 Oct 2016 16:47:45 +0200 Subject: [PATCH] New script to add the directory name as an exif tag to images --- tag_photo.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 tag_photo.sh diff --git a/tag_photo.sh b/tag_photo.sh new file mode 100755 index 0000000..b4b91f0 --- /dev/null +++ b/tag_photo.sh @@ -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