I need script that renames all title files (.srt) to the same name just diffrent number. For example when i download title, its name is “SHOWNAME.S03E02.720p.5.1Ch.Web-DL.ReEnc-DeeJayAhmed_bs.srt” or something like that. That files should be renamed to “Showname_S03E{episode}.srt”
My script goes trough all of the files in one folder (16 files in total) and checks 2 things:
If the file has correct name (showname variable)
If the file has correct sufix (suf variable)
It should also check rename order by checking Episode number and changeing it only if its in order.
That means it should go trough all files until it finds file with E01 in its name and then rename it.
After that go again trough all files until it finds E02 and so on…
count variable is number of files in folder
Im stuck in infinite loop because its stuck on first file witch name doesnt have E01 in its name. Any help?
while not count == 0:
for file in os.listdir(path):
if showname and suf in file.capitalize():
if f'E{episode:02}' in file:
file = f'{path}\{file}'
if episode < 10 : newname = f'Suits_S0{season}E0{episode}'
else: newname = f'Suits_S0{season}E{episode}'
newname = f'{path}\{newname}{suf}'
os.rename(file, newname)
episode = episode + 1
count = count - 1
else: break
break
pejcaa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.