Skip to content

Instantly share code, notes, and snippets.

@tossmilestone
Created December 8, 2020 13:02
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 tossmilestone/972658dab69cbbca8a3de05dc6170821 to your computer and use it in GitHub Desktop.
Save tossmilestone/972658dab69cbbca8a3de05dc6170821 to your computer and use it in GitHub Desktop.
A simple batch rename python script
import os
import re
regex = r"\[(\d+)\]"
for f in os.listdir("./"):
if f.endswith(".mp4"):
matches = re.finditer(regex, f, re.MULTILINE)
for num, match in enumerate(matches, start=1):
ep = match.group(1)
print(r'TV.%s.mp4' % ep)
os.rename(f, r'TV.%s.mp4' % ep)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment