Skip to content

Instantly share code, notes, and snippets.

@crookm
Last active January 10, 2019 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crookm/c8cc8fa0a2b303d64f5b23191491bbfc to your computer and use it in GitHub Desktop.
Save crookm/c8cc8fa0a2b303d64f5b23191491bbfc to your computer and use it in GitHub Desktop.
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