Skip to content

Instantly share code, notes, and snippets.

@andersonvom
Created August 26, 2012 15:53
Show Gist options
  • Save andersonvom/3481270 to your computer and use it in GitHub Desktop.
Save andersonvom/3481270 to your computer and use it in GitHub Desktop.
Shift camera picture filenames by a certain amount to avoid files with same name
#!/bin/bash
INITIAL_NUM=1012
SEPARATOR='_'
for i in *.JPG
do
basename=`basename $i .JPG`
prefix=`echo $basename | cut -d $SEPARATOR -f1`
current_num=`echo $basename | cut -d $SEPARATOR -f2`
new_num=`expr $INITIAL_NUM + $current_num`
mv $i ${prefix}${SEPARATOR}${new_num}.JPG
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment