Snippets

malte flender Script for editing jpg meta data

Created by malte flender
#!/bin/sh

# Copyright 2016 Malte Flender
# This file is part of a Malte project.
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation version 2 of the License only.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright_Owner="Malte Flender"
File_Path=$1

# Errorhandling:
# print the actual command and exit if something went wrong
edo()
{
    echo "$@" 1>&2
    "$@" || exit 1
}

# If less than 1 arguments are given exit
die() {
  echo "$@"
  exit 1
}

[[ $# -eq 1 ]] || die "not enough arguments"

# Say which file
echo $File_Path

# Get title and keywords from prompt
read -e -p "Enter the Title: `echo $'\n> '`" IPTC_Caption
read -e -p "Enter the Keywords: `echo $'\n> '`" IPTC_Keywords

# Remove all (inclusive adobe) metadata from file exept the ICC Profile
edo exiftool -overwrite_original -all= --icc_profile:all ${File_Path}
edo exiftool -overwrite_original -adobe=  ${File_Path}

# Add IPTC Caption
edo exiftool -overwrite_original -m -iptc:headline="${IPTC_Caption}" ${File_Path}
edo exiftool -overwrite_original -m -iptc:caption-abstract="${IPTC_Caption}" ${File_Path}

# Add IPTC Keywords
edo exiftool -overwrite_original -m -iptc:keywords="${IPTC_Keywords}" ${File_Path}

# Add IPTC Copyright
edo exiftool -overwrite_original -m -iptc:CopyrightNotice="${Copyright_Owner}" ${File_Path}

# Show all tags as result after a blank line
echo 
edo exiftool -a -u -g1 ${File_Path}

Comments (0)