Created
January 19, 2015 21:22
-
-
Save cristianmiranda/a2f33a5d94cb86c1546c to your computer and use it in GitHub Desktop.
Series Episodes renamer script
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/sh | |
episodes="*" | |
regex="Seinfeld Season ([[:digit:]]{1,2}) Episode ([[:digit:]]{1,2}) - ([a-zA-Z0-9_\& \-]*)(.mkv|.srt)" | |
for f in $episodes | |
do | |
if [[ $f =~ $regex ]]; then | |
season="${BASH_REMATCH[1]}" | |
episode="${BASH_REMATCH[2]}" | |
name="${BASH_REMATCH[3]}" | |
extension="${BASH_REMATCH[4]}" | |
old_name="${BASH_REMATCH[0]}" | |
new_name="Seinfeld S${season}E${episode} - ${name}${extension}" | |
mv "${old_name}" "${new_name}" | |
echo "--> ${new_name}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment