Skip to content

Instantly share code, notes, and snippets.

@paravar
Created September 24, 2017 14:02
Show Gist options
  • Save paravar/1c68d612d6cf24ed46c0f4ab087a8294 to your computer and use it in GitHub Desktop.
Save paravar/1c68d612d6cf24ed46c0f4ab087a8294 to your computer and use it in GitHub Desktop.
#! /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())
@paravar
Copy link
Author

paravar commented Sep 24, 2017

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 >>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment