Skip to content

Instantly share code, notes, and snippets.

@wangyung
Last active September 14, 2020 15:32
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 wangyung/1dd50dacc942b1cc0bc5dd04a8d2d100 to your computer and use it in GitHub Desktop.
Save wangyung/1dd50dacc942b1cc0bc5dd04a8d2d100 to your computer and use it in GitHub Desktop.
Change all file names by incremental number. #tips
#!/bin/bash
INDEX=1
for file in `ls | sort -g`
do
filename=$(basename "$file")
extension=${filename##*.}
filename=$(printf "%03d\n" $INDEX)
mv "$file" "$filename.$extension"
((INDEX=$INDEX+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment