Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active August 29, 2015 14:21
Show Gist options
  • Save magnetikonline/189b514e0ef8b414856f to your computer and use it in GitHub Desktop.
Save magnetikonline/189b514e0ef8b414856f to your computer and use it in GitHub Desktop.
Bash script to rename collection of JPG images with numeric index, ordered by date created.
#!/bin/bash
IFS=$'\n'
counter=1
for file in $(ls -1tr *.jpg); do
mv "$file" "$(printf "img_%04d.jpg" "$counter")"
counter=$(($counter + 1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment