Last active
September 14, 2020 15:32
-
-
Save wangyung/1dd50dacc942b1cc0bc5dd04a8d2d100 to your computer and use it in GitHub Desktop.
Change all file names by incremental number. #tips
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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