608a1e8df79675ff0646c63026ed139dc1e58a18
2 # Desc: Apply metadata to photos
3 # Usage: bkphotometa.sh [FILE in]
4 # Ref/Attrib: [1]. Creative Commons XMP recommendation. (2015). https://wiki.creativecommons.org/wiki/XMP
5 # [2]. Eva, Johannes. (2023-03-30). “How to edit EXIF metadata via the command line with ExifTool”. libre-software.net. https://libre-software.net/linux/edit-metadata-exiftool/
7 # Depends: exiftool 12.16 (https://exiftool.org/ )
10 strCreator
="Steven Baltakatei Sandoval";
11 strCreatorURL
="https://baltakatei.com";
12 strTerms
="This work is licensed to the public under the Creative Commons Attribution-ShareAlike license http://creativecommons.org/licenses/by-sa/4.0/ .";
13 strLicenseURL
="http://creativecommons.org/licenses/by-sa/4.0/";
15 yell
() { echo "$0: $*" >&2; } # print script path and all args to stderr
16 die
() { yell
"$*"; exit 111; } # same as yell() but non-zero exit status
17 must
() { "$@" || die
"cannot $*"; } # runs args as command, reports args if command fails
23 if [[ ! -f "$1" ]]; then die
"FATAL:Not a file:$1"; fi;
24 if ! command -v exiftool
1>/dev
/random
2>&1; then
25 die
"FATAL:exiftool not available. See https://exiftool.org/ ."; fi;
28 # Check if exiftool recognizes the file format
29 if ! exiftool
-s -FileType "$file_in" 1>/dev
/random
; then
30 yell
"ERROR:File type not recognized by exiftool:$file_in";
33 # Change file metadata
35 cmd_args
+=("exiftool");
36 # cmd_args+=("-overwrite_original"); # hashtag reckless
39 cmd_args
+=("-XMP-dc:Rights=""$value"); unset value
;
42 cmd_args
+=("-XMP-xmpRights:Marked=""$value"); unset value
;
45 cmd_args
+=("-XMP-xmpRights:UsageTerms=""$value"); unset value
;
47 value
="$strLicenseURL";
48 cmd_args
+=("-XMP-cc:license=""$value"); unset value
;
51 cmd_args
+=("-XMP-cc:AttributionName=""$value"); unset value
;
53 value
="$strCreatorURL";
54 cmd_args
+=("-XMP-cc:AttributionURL=""$value"); unset value
;
56 cmd_args
+=("$file_in");
64 # Author: Steven Baltakatei Sandoval