Project

General

Profile

Download (822 Bytes) Statistics
| Branch: | Tag: | Revision:
ba1e6b20 dsorber
import os
import re
import sys

def main():
if len(sys.argv) < 3:
print 'Not enough arguments specified!'
return

show_name = sys.argv[1]
directory = sys.argv[2]

show_name = show_name.replace(' ', '\.')

for filename in os.listdir(directory):
m = re.match("^(%s)\.S(\d+)E(\d+)\.(.*)\.(\w{3})$" % show_name, filename, re.IGNORECASE)
if m:
new_name = '%s - S%sE%s.%s' % (show_name.replace('\.', ' '),
m.group(2), m.group(3), m.group(5).lower())

print '%s --- MATCH: %s' % (filename, new_name)
os.rename(os.path.join(directory, filename),
os.path.join(directory, new_name))
else:
print filename

if __name__ == '__main__':
sys.exit(main())