Created
September 10, 2017 06:47
-
-
Save YanhaoYang/0851f15b260516326ba7ba2fcb23bdd0 to your computer and use it in GitHub Desktop.
Rename files by index
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 | |
files="*.mp4" | |
regexp="([0-9]+).mp4" | |
for i in $files | |
do | |
if [[ $i =~ $regexp ]] | |
then | |
idx="${BASH_REMATCH[1]}" | |
name=$(printf "%02d" $idx) | |
echo "rename \"$i\" -> \"$name - $i\"" | |
#mv "$i" "$name - $i" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment