Last active
January 10, 2019 03:08
-
-
Save crookm/c8cc8fa0a2b303d64f5b23191491bbfc to your computer and use it in GitHub Desktop.
Quick python 3 program to rename files for downloaded TV series
This file contains hidden or 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
import glob, os, re | |
os.chdir('/directory/you/want/to/work/in') | |
for file in glob.glob('*[sS][0-9][0-9][eE][0-9][0-9]*'): | |
ep_string = re.search('[sS][0-9]{2}[eE][0-9]{2}', file).group(0).upper() | |
file_type = file.split('.')[-1] | |
new_name = ep_string + '.' + file_type | |
print(new_name) | |
os.rename(file, new_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment