From 3173d8de337e052dfb1ec4ee663062a805c6f70e Mon Sep 17 00:00:00 2001 From: Adam Starbuck Date: Tue, 4 Dec 2018 23:30:16 -0600 Subject: [PATCH] Add regex for movies to allow periods in name adds ability to see movies files split by periods (.) versus just spaces and parenthesis. Tested with previously acceptable filename formats as well as `Movie.Title.0000.*` formats --- other/movie-tv2folder.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/other/movie-tv2folder.py b/other/movie-tv2folder.py index 34a9f8d..51526f2 100644 --- a/other/movie-tv2folder.py +++ b/other/movie-tv2folder.py @@ -12,6 +12,7 @@ # Movie Title (2017) 1080p.mkv # Movie Title (2017) anything else.* # Movie Title (2017).* +# Movie.Title.2017.* # Movie Title.mkv --> **would not be moved, since missing (year)** # # Series: (scans 2 folders deep) @@ -81,10 +82,10 @@ def do_it(src_path, dst_path, depth): continue #movies - if depth == 0: - r = re.match("^(.+?\\([0-9]{4}\\)).*", name, re.I) + if depth == 0: + r = re.match("^(.+?)\W(\d{4})", name, re.I) #adds ability to see movies files split by periods (.) versus just spaces and parenthesis if r: - dst_pathname = os.path.join(os.path.join(dst_path, str(r.group(1))), name) + dst_pathname = os.path.join(os.path.join(dst_path, str(r.group(1).replace(".", "")).strip()+" ("+str(r.group(2))+")"), name) print("files2folders.py: movie: " + pathname + " -> " + dst_pathname) my_rename(pathname, dst_pathname) continue @@ -98,5 +99,4 @@ def do_it(src_path, dst_path, depth): break; #abort recursion in os.walk() - do_it(src_root_path, dst_root_path, 0)