From e6f60f264296413d894d96b4025db9d76b372dc7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Mon, 20 Aug 2012 10:35:14 -0400 Subject: [PATCH] Rename related files in name-by-date.sh (XYZ.jpg and XYZ.mov stay together). --- posts/name-by-date/name-by-date.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/posts/name-by-date/name-by-date.sh b/posts/name-by-date/name-by-date.sh index 57feb2e..c5eea1e 100755 --- a/posts/name-by-date/name-by-date.sh +++ b/posts/name-by-date/name-by-date.sh @@ -2,7 +2,7 @@ # # Rename JPEGs to reflect the creation date stored in their metadata. # -# Copyright (C) 2010-2011 W. Trevor King +# Copyright (C) 2010-2012 W. Trevor King # # 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 @@ -69,6 +69,16 @@ while [ -n "$1" ]; do fi if [ "$NEW_NAME" != "$FILE" ]; then "${MV}" "$FILE" "$NEW_NAME" + BASE="${FILE%.*}" + NEW_BASE="${NEW_NAME%.*}" + for AUXILIARY in "${BASE}"*; do + if [ "${AUXILIARY}" != "${BASE}*" ]; then + EXTENSION="${AUXILIARY:${#BASE}}" + NEW_AUXILIARY="${NEW_BASE}${EXTENSION}" + echo "Auxiliary file ${AUXILIARY} -> ${NEW_AUXILIARY}" + "${MV}" "${AUXILIARY}" "${NEW_AUXILIARY}" + fi + done fi fi fi -- 2.26.2