Skip to content

Instantly share code, notes, and snippets.

@lee2sman
Created July 17, 2015 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lee2sman/ec30cf3032d1c3554181 to your computer and use it in GitHub Desktop.
Save lee2sman/ec30cf3032d1c3554181 to your computer and use it in GitHub Desktop.
rename all files in a folder sequentially
#!/bin/bash
# batch rename all items in a folder regardless of title into sequential number order
# warning: will throw an error if you have any
i=1
for f in *.jpg # remove .jpg if you want to force rename all files but be careful. Also: will throw error with directories
do mv "$f" "$( printf "%02d.jpg" $i )" # the 02d means generate file numbers 00-99. use 3d for 000-999.
((i++))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment