From: W. Trevor King Date: Mon, 20 Aug 2012 14:35:14 +0000 (-0400) Subject: Rename related files in name-by-date.sh (XYZ.jpg and XYZ.mov stay together). X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e6f60f264296413d894d96b4025db9d76b372dc7;p=blog.git Rename related files in name-by-date.sh (XYZ.jpg and XYZ.mov stay together). --- 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