【代码】
=================================================
#适用于版本3.3
import os
import re
import sys
#代码设置
#前缀、后缀、扩展名、正则串
strPrefix = "大悬疑"
strSuffix = "艾宝良"
strFileExt = "mp3"
strReGetNum = r"\D+(\d+).*"
#预处理
reGetNum = re.compile(strReGetNum)
path = os.getcwd()
fileList = os.listdir(path)
#开始重命名
print("=======================================")
for fileNum, fileName in enumerate(fileList):
if(fileName.split('.')[-1] == strFileExt):
num = reGetNum.search(fileName).group(1)
print(num + ' ' + fileName, end = "")
if num:
newName = strPrefix + num + strSuffix + '.' + strFileExt
os.rename(fileName, newName)
print(' ==> ' + newName)
else:
print("")
print("=======================================")
print("转换完成")