# coding=utf-8
import re
import os
import sys
def rename():
path = "E:\\Website\\test\\".decode('utf-8').encode('GB2312')
filelist = os.listdir(path)
for files in filelist:
olddir=os.path.join(path,files)
if os.path.isdir(olddir):
continue
filename=os.path.splitext(files)[0]
filetype=os.path.splitext(files)[1]
#替换文件中的数字==还有a
news = re.sub('\d*==','',filename)
news = re.sub('\d*=','',news)
nn = news.replace("a","")
print(os.path.join(path,nn+filetype))
newdir = os.path.join(path,nn+filetype.lower())
#重名 判断
if os.path.isfile(newdir):
print(newdir+" is have")
continue
os.rename(olddir,newdir)
rename()