Skip to content

Instantly share code, notes, and snippets.

@xight
Created June 18, 2018 04:19
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 xight/b2a32ca28a6e32e1ea7e0ada7964371f to your computer and use it in GitHub Desktop.
Save xight/b2a32ca28a6e32e1ea7e0ada7964371f to your computer and use it in GitHub Desktop.
Rename file to continuous number
#!/bin/bash
extension='jpg'
prefix=`date +%Y-%m-%d`
count=1
for FILE in `find ./ -type f -name '*'.${extension} -maxdepth 1`;
do
mv $FILE ${prefix}-`printf '%04g\n' $count`.${extension}
count=$(($count + 1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment