import glob
import os
import re
path=r"F:\源码收集\python\python视频\*\*\*.mp4"
allmp4 = glob.glob (path)
#去除的字符串
partern = ["[ www.ruike1.com ]【瑞客 .论坛 www.ruike1.com】",
"[ www.ruike1.com ]【瑞客论 坛 www.ruike1.com】",
"【瑞客 论坛 www.ruike1.com】",
"【瑞 客 论坛 www.ruike1.co m】",
"【瑞 客论 坛 www.ruike1.com】",
"【瑞 客论 坛 www.ruike1.com】",
"【瑞 客 论坛 www.ruike1.com】",
"【瑞 客 论 .坛 www.ruike1.com】",
"【瑞 客 论 坛 www.ruike1.com】",
"[ www.ruike1.com ]【瑞 客 论坛 www .ruike1.com】",
"【瑞 客 论 坛 www.ruike1.com】",
"【瑞 客 论坛 www.ruike1.com】",
"[ www.ruike1.com ]【瑞客 论 坛 www.ruike1.com】",
"【瑞 z客 论坛 www.ruike1.com】",
"【瑞客论-坛 www.ruike1.com】"
]
#改名函数
def rename(old,new):
os.renames(old,new)
#双循环in匹配字符串
for i in allmp4 :
for s in partern:
if s.strip() in i:
w=i.replace(s,"")
print(w)
rename(i,w)