Created
June 29, 2021 17:59
-
-
Save sixem/7d6ad625f6b877d031c332ebab74ee8a to your computer and use it in GitHub Desktop.
Sequential rename of files by index
This file contains 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=0 | |
find . -type f | while read FILE; do | |
BASENAME=$(basename "$FILE") | |
EXTENSION="${BASENAME##*.}" | |
FILENAME="${BASENAME%.*}" | |
echo "$FILENAME.$EXTENSION -> $INDEX.$EXTENSION" | |
mv "$FILENAME.$EXTENSION" "$INDEX.$EXTENSION" | |
INDEX=$((INDEX+1)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment