Just For Fun

Just the other day…

import re, os
avi_re = '(Friends)(\\.)(S)(01)(E)(?P<epi>.*?)(\\.)(DVDRip)(\\.)(XviD)(\\.)(avi)'
sub_re = '(Friends)( )(-)( )(1)(\\.)(?P<epi>\w+)(?P<name>.*?)(\\(EN\\))(\\.)(sub)'

for avi_f in filelist:
  if re.match(avi_re, avi_f):
    e = re.match(avi_re, avi_f).group('epi')
    for sub_f in filelist:
      if re.match(sub_re, sub_f):
        ep = re.match(sub_re, sub_f).group('epi')
        if e == ep:
          new = 'Friends - 1.' + ep + re.match(sub_re, sub_f).group('name')
          os.rename(avi_f, new + '.avi')
          os.rename(sub_f, new + '.sub')

because I can! 😉

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s