Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Mass File Rename with Pattern

import os,re
from shutil import move

p=r'E:\TVS\Flash'
s=0
from sub import correctSubtitleEncoding
enc=0
if not enc:os.chdir(p)
ext='.srt'
pre=''
# pre='Flash.'
# ext='.480p.srt'
for i,j in enumerate(os.listdir(p)):
if s: #srt
if( j.endswith('.srt')):
if enc:
t=(p+'\\'+j)
# print(p+'\\'+j)
correctSubtitleEncoding(t)
else:
z=(((re.search(r'(.*?(S\d\dE\d\d))',j,re.I)[1])))+ext
# (?# z=(((re.search(r'(?:.*?)(S\d\dE\d\d)',j,re.I)[1])))+ext)
move(j,pre+z)
print(z)
else: #mkv
e='.mkv'
if( j.endswith(e)):
z=(((re.search(r'(.*?(S\d\dE\d\d))',j,re.I)[1])))+e
move(j,pre+z)
print(pre+z)
# move(j,t)



This post first appeared on SMARTMANOJ, please read the originial post: here

Share the post

Mass File Rename with Pattern

×

Subscribe to Smartmanoj

Get updates delivered right to your inbox!

Thank you for your subscription

×