my-scripts/jpg-add-comment.sh

32 lines
995 B
Bash

#!/bin/bash
# Add a exif-comment to all JPEG-Files from this directory and all subdirectorys
#
# (c) LUG-VS (GPL)
VERSION="make_exif-name.sh Version 0.0.2 from 23.10.2005"
#
# Input: comment text
# Output: changed files
#
# Changes:
# 0.0.2: comment as parameter from commandline
# 0.0.1: generation
#
COMMENTSTEXT=$*
JPEGFILEFILTER=*.jpg
# trap is executed if script breaks
trap "echo '*** TRAP ***' ; exit" ERR
# check if command exists else break
which exiftran > /dev/null || echo "exiftran not found!" || exit;
echo "Write Comment: <"${COMMENTSTEXT}">"
# for each file in JPEGFILEFILTER do
# exiftran - transform digital camera jpeg images and use the libexif-Library
# -i Enable inplace editing of the images.
# -b Create a backup file when doing inplace editing.
# -p Preserve timestamps (atime + mtime) when doing inplace editing.
# -c <text> Set jpeg comment tag to <text>.
find . -type f -name "${JPEGFILEFILTER}" -exec exiftran -ibp -c "${COMMENTSTEXT}" {} \;