From 1ce0990d5ca83a79c1ad1f79c5f30b417b945179 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Mon, 1 Aug 2011 22:23:24 +0200 Subject: [PATCH] add rename-photos --- rename-photos | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 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 -- 2.39.5