From: Martin Pitt Date: Mon, 1 Aug 2011 20:23:24 +0000 (+0200) Subject: add rename-photos X-Git-Url: https://piware.de/gitweb/?a=commitdiff_plain;h=1ce0990d5ca83a79c1ad1f79c5f30b417b945179;p=bin.git add rename-photos --- diff --git a/rename-photos b/rename-photos new file mode 100755 index 0000000..20ff431 --- /dev/null +++ b/rename-photos @@ -0,0 +1,24 @@ +#!/bin/sh +set -e + +num=1 + +if [ -n "$DEBUG" ]; then + PREFIX=echo +fi + +for f in *.JPG *.jpg; do + [ -f "$f" ] || continue + title=`exiv2 pr -Pv -gXmp.photoshop.Headline "$f"` || title='' + newname=`printf "%03i" $num` + if [ -n "$title" ]; then + newname="$newname - $title" + fi + newname="$newname.jpg" + if [ -e "$newname" ]; then + echo "Error: new name $newname for $f already exists, aborting" >&2 + exit 1 + fi + $PREFIX mv "$f" "$newname" + num=$((num+1)) +done