Created
October 6, 2018 17:44
-
-
Save robotman321/0d614cd95e4f834aa4bef2aea58ae5a6 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import re | |
import os | |
pattern = re.compile(r'\[(.*)\] (.*) - (\d*) (\d*p) \[anidb-(\d*)\].mp4') | |
for i,j,y in os.walk('.'): | |
#i - directory | |
#y list of files. | |
#for filename in os.listdir("H:\Hunter x Hunter (2011)"): | |
if len(y) > 0: | |
if len(y) < 100: | |
longformat = False | |
else: | |
longformat = True | |
for filename in y: | |
if pattern.match(filename): | |
g = pattern.search(filename) | |
if longformat: | |
episode = str("{0:0=3d}".format(int(g.group(3)))) | |
else: | |
episode = str("{0:0=2d}".format(int(g.group(3)))) | |
fansub = g.group(1) | |
seriesname = g.group(2) | |
anidbid = g.group(5) | |
epformat = g.group(4) | |
newname = "[" + fansub + "] " + seriesname + " - " + episode + " " + epformat + " [anidb-" + anidbid + "].mp4" | |
oldname = r"{0}\{1}".format(i,filename) | |
newformatname = r"{0}\{1}".format(i,newname) | |
os.rename(oldname, newformatname) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment