Script to rename 001-005 epiodes

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
xexe Offline
Fan
Posts: 711
Joined: Sep 2008
Reputation: 1
Post: #1
I can across a problem where XBMC was adding episodes to the library incorrectly.

Files like:

show.S01E01-06.XviD-GROUP.avi

were added as two eps instead of as per this example six.

spiff cobbled together this script which renamed this example to:

show.S01E01E02E03E04E05E06.XviD-GROUP.avi

I should point out this was a quick hack for me and this pecific exmaple but it should at least work as a cheat sheet for others in the future.

Code:
#!/bin/bash

ep1=`echo $1 | awk -F '-' '{print $1}'`
ep2=`echo $1 | awk -F '-' '{print $2}'`
prefix=`echo $1 | awk -F 'E0' '{print $1'}`
postfix=`echo $1 | awk -F 'DVDRip' '{print $2'}`
ep1=${ep1:(-2)}
ep2=${ep2:1:2}

for i in `seq $ep1 $ep2`; do
    prefix+=E`printf %02i $i`
done
prefix+=$postfix

echo mv $1 $prefix


Having problems getting your TV shows recognized?

Try my extra TV show matching REGEX here
find quote