把类似这样的文件名,
批量重命名为这样的。
效果:
#coding=utf-8
import os
import re
dir="e:\\yu"
regx = '\d\d'
for root,dirs,files in os.walk(dir):
for file in files:
file_name = os.path.join(root,file)
part = re.findall(regx,file_name)[0]
newfilename = "武则天"+str(part)+'.txt'
os.renames(os.path.join(root,file),os.path.join(root,newfilename))