import os
import re
# 获取当前工作目录的路径
directory = os.getcwd()
# 遍历文件夹中的所有文件
for filename in os.listdir(directory):
# 使用正则表达式匹配文件名
match = re.search(r'^([a-zA-Z]+).S(\d{2})E(\d{2})\.(.*)', filename)
if match:
# 构建新的文件名,保持剧集名称和季集编号不变,替换后面的部分为 'test'
new_filename = f"{match.group(1)}.S{match.group(2)}E{match.group(3)}.Bluray.1080p.x264.AC3.KiMSTeR.tBluray.1080p.x264.AC3.KiMSTeR"
# 获取文件的完整路径
old_file = os.path.join(directory, filename)
new_file = os.path.join(directory, new_filename)
# 重命名文件
os.rename(old_file, new_file)
print(f"Renamed '{filename}' to '{new_filename}'")