Skip to content

Instantly share code, notes, and snippets.

@magicleon94
Created August 29, 2017 13:37
Show Gist options
  • Save magicleon94/a4f8b1de81d1f82dcc0e54ebbe0c7318 to your computer and use it in GitHub Desktop.
Save magicleon94/a4f8b1de81d1f82dcc0e54ebbe0c7318 to your computer and use it in GitHub Desktop.
Renamer for TV series name with structure "Series Name Season XX Episode XX Title"
#!/bin/bash
seasonNo=$1
maxNo=$2
if [ "$#" -ne "2" ]; then
echo "Illegal number of parameters"
echo "Usage: $0 seasonNumber episodeNumber"
fi
for i in $(eval echo {1..$2})
do
# to create dummies for tests:
# touch "Nome serie Season $(printf "%02d" $1) Episode $(printf "%02d" $i) Titolo$i.avi"
replaced=$(ls | grep "Season 0\?$1 Episode 0\?$i\ ")
newName=$(printf "S%02dE%02d.avi" $1 $i)
echo "Replacing $replaced with $newName"
mv "$replaced" "$newName"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment