Created
September 24, 2017 14:02
-
-
Save paravar/1c68d612d6cf24ed46c0f4ab087a8294 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/python3 | |
""" This script is to rename the files | |
"Friends Season ## Episode ## - *.avi" | |
to | |
"Friends S##E## - *.avi" | |
Example: | |
This: | |
"Friends Season 09 Episode 01 - The One Where No One Proposes.avi" | |
will be changed to: | |
"Friends S09e01 - The One Where No One Proposes.avi" | |
""" | |
import os | |
import shutil | |
import re | |
series_pattern = re.compile(r'^(.*)(Season )(/d{2})( Episode )(/d{2})(.*)$') | |
sample_string = "Friends Season 09 Episode 01 - The One Where No One Proposes\ | |
.avi" | |
result = series_pattern.search(sample_string) | |
print(result.group()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
17:30 ~/python/lab/ali_pracitices/batch_rename >>./batch_rename.py
Traceback (most recent call last):
File "./batch_rename.py", line 22, in
print(result.group())
AttributeError: 'NoneType' object has no attribute 'group'
17:33 ~/python/lab/ali_pracitices/batch_rename >>