
Explain yourself with reStructured Text, embedded code, graphs, charts, and LaTeX–style math.
Join Siafoo Now
or
Learn More
TV Show episode organizing script
0
Updated over 9 years ago (24 Jan 2010 at 06:09 PM)
recent activity
In Brief | A simple script for moving TV show episodes to their appropriate folders...... more |
Language | Python |
# 's
1#!/usr/bin/python
2
3'''
4Created on Dec 4, 2009
5
6@author: stou@icapsid.net
7@license: Public Domain
8'''
9
10import re, sys
11from os import path
12from subprocess import check_call
13
14base_folder = '~/Shows'
15
16def main(argv):
17
18 if not argv:
19 print >> sys.stderr, 'Enter URLS on the command line'
20 return
21
22 for show_src_path in argv:
23
24 show_str = show_src_path.split('/')[-1]
25
26 name, season, episode, rest = re.findall('(.*)\.[S|s]?(\d+)[x|e|E](\d+)(.*)', show_str)[0]
27
28 season = int(season)
29 episode = int(episode)
30
31 name = '.'.join([n.capitalize() for n in name.split('.')])
32
33 show_dest_path = '%s/%s/S%02i/' % (base_folder, name, season)
34 show_new_name = '%s.S%02iE%02i%s' % (name, season, episode, rest)
35
36 show_dest_path = path.expanduser(show_dest_path)
37
38 if not path.exists(show_dest_path):
39 print >> sys.stderr, 'directory does not exist'
40 continue
41
42 check_call(['kde-mv', show_src_path, show_dest_path + show_new_name])
43
44if __name__ == "__main__":
45 main(sys.argv[1:])
A simple script for moving TV show episodes to their appropriate folders...
Set the base_folder to the path where you keep all of your shows. Then run the script giving the names of the episodes on the command line: python mf_shows.py SomeShow.s01e03.avi SomeOtherShow.s03e04.mkv and the files will be moved to ../SomeShow/S01 and ../SomeOthershow/S03.
This script does not create directories if they are missing in order to prevent a weird file name from creating random folders in weird places.
Add a Comment