I have 291 episodes named tv.show.01.mp4 to tv.show.291.mp4 and i want rename them to be named like Tv Show Episode S01E01.mp4. I use Linux so please suggest only FOSS compatible programs

  • @INeedMana
    link
    1
    edit-2
    2 years ago

    I might have messed something up but I think you should be able to take it from here:

    function split_season() { 
      S=$((($1-1)/$2))
      E=$(($1-$S*$2))
      printf "S%02dE%02d" $(($S+1)) $E  
    }
    
    EPISODES_PER_SEASON=15
    
    for f in tv.show.*.mp4; do
      NUMBER=`echo $f|sed 's/[^[:digit:]]*\([[:digit:]]*\).mp4/\1/'`
      #maybe put echo at the beginning of the next line to test before moving?
      mv "$f" "Tv Show $(split_season $NUMBER $EPISODES_PER_SEASON).mp4"
    done