Skip to content

Instantly share code, notes, and snippets.

@levhita
Last active November 6, 2015 20:08
Show Gist options
  • Save levhita/d5fbddddae1c5a16fad6 to your computer and use it in GitHub Desktop.
Save levhita/d5fbddddae1c5a16fad6 to your computer and use it in GitHub Desktop.
Renames all jpgs in a folder sequentially, I use it to make surveillance bulk files compatible with OpenShot import functionality.
if [ ! -d "$1" ]; then
echo "Directory doesnt exists"
exit
fi
cd $1
a=1
for i in *.jpg; do
new=$(printf "%09d.jpg" "$a") #09 pad to length of 9
mv -- "$i" "$new"
let a=a+1
done
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment