import os
def batch_rename(folder_path, search_str, replace_str):
for root, _, files in os.walk(folder_path):
for filename in files:
if search_str in filename:
new_filename = filename.replace(search_str, replace_str)
old_path = os.path.join(root, filename)
new_path = os.path.join(root, new_filename)
os.rename(old_path, new_path)
print(f"Renamed: {filename} -> {new_filename}")
if __name__ == "__main__":
folder_path = "F:\\test\\out\\skin\\" # 替换为你的文件夹路径
search_str = "125_.png"
replace_str = "125.png"
batch_rename(folder_path, search_str, replace_str)
使用Python3运行