Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick python 3 program to rename files for downloaded TV series
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
You can’t perform that action at this time.