]> piware.de Git - bin.git/commitdiff
process-photos: Add
authorMartin Pitt <martin@piware.de>
Sat, 5 Nov 2022 06:48:57 +0000 (07:48 +0100)
committerMartin Pitt <martin@piware.de>
Sat, 5 Nov 2022 06:51:04 +0000 (07:51 +0100)
Rename photos according to EXIF original date/time, and copy tags to
IPTC Description where Sigal can use them.

process-photos [new file with mode: 0755]

diff --git a/process-photos b/process-photos
new file mode 100755 (executable)
index 0000000..14ee5b3
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+set -eu
+
+for f in *.jpg *.JPG; do
+    echo "$f"
+    chmod 644 "$f"
+    info="$(exiv2 -Pnv "$f")"
+    # copy tags to IPTC description (sigal)
+    tags=$(echo "$info" | sed -n 's/^subject *//p' | tr '[:upper:]' '[:lower:]')
+    if [ -n "$tags" ]; then
+        exiv2 -M"add Iptc.Application2.Caption String $tags" mo "$f"
+    fi
+
+    # rename to EXIF date, if available
+    if echo "$info" | grep -q '^DateTime'; then
+        exiv2 mv "$f"
+    fi
+done