Rename related files in name-by-date.sh (XYZ.jpg and XYZ.mov stay together).
authorW. Trevor King <wking@tremily.us>
Mon, 20 Aug 2012 14:35:14 +0000 (10:35 -0400)
committerW. Trevor King <wking@tremily.us>
Mon, 20 Aug 2012 14:35:14 +0000 (10:35 -0400)
posts/name-by-date/name-by-date.sh

index 57feb2efa57086b805b75d58027abbeefd5a786b..c5eea1e69bb94b19aa8427a37ca3199438b2f9ff 100755 (executable)
@@ -2,7 +2,7 @@
 #
 # Rename JPEGs to reflect the creation date stored in their metadata.
 #
-# Copyright (C) 2010-2011 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2012 W. Trevor King <wking@tremily.us>
 #
 # 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