import os
import sys

rename_map = {
    "segment_1.png": "segment_001.png",
    "segment_2.png": "segment_002.png",
    "segment_3.png": "segment_003.png",
    "segment_4.png": "segment_004.png",
    "segment_5.png": "segment_005.png",
    "segment_6.png": "segment_006.png",
    "segment_7.png": "segment_007.png",
    "segment_8.png": "segment_008.png",
    "segment_9.png": "segment_009.png",
    "segment_10.png": "segment_011.png",

    "segment_11.png": "segment_013.png",
    "segment_12.png": "segment_015.png",
    "segment_13.png": "segment_017.png",
    "segment_14.png": "segment_010.png",
    "segment_15.png": "segment_012.png",
    "segment_16.png": "segment_014.png",
    "segment_17.png": "segment_016.png",
    "segment_18.png": "segment_018.png",
    "segment_19.png": "segment_019.png",
    "segment_20.png": "segment_021.png",

    "segment_21.png": "segment_023.png",
    "segment_22.png": "segment_025.png",
    "segment_23.png": "segment_027.png",
    "segment_24.png": "segment_020.png",
    "segment_25.png": "segment_022.png",
    "segment_26.png": "segment_024.png",
    "segment_27.png": "segment_026.png",
    "segment_28.png": "segment_029.png",
    "segment_29.png": "segment_031.png",
    "segment_30.png": "segment_033.png",

    "segment_31.png": "segment_035.png",
    "segment_32.png": "segment_028.png",
    "segment_33.png": "segment_030.png",
    "segment_34.png": "segment_032.png",
    "segment_35.png": "segment_034.png",
    "segment_36.png": "segment_036.png",
    "segment_37.png": "segment_037.png",
    "segment_38.png": "segment_039.png",
    "segment_39.png": "segment_041.png",
    "segment_40.png": "segment_043.png",

    "segment_41.png": "segment_045.png",
    "segment_42.png": "segment_038.png",
    "segment_43.png": "segment_040.png",
    "segment_44.png": "segment_042.png",
    "segment_45.png": "segment_044.png",
    "segment_46.png": "segment_047.png",
    "segment_47.png": "segment_049.png",
    "segment_48.png": "segment_051.png",
    "segment_49.png": "segment_053.png",
    "segment_50.png": "segment_046.png",

    "segment_51.png": "segment_048.png",
    "segment_52.png": "segment_050.png",
    "segment_53.png": "segment_052.png",
    "segment_54.png": "segment_054.png",

    # 添加更多的文件映射关系
}

def rename_files(folder_path):
    if not os.path.isdir(folder_path):
        print(f"错误：{folder_path} 不是一个有效的文件夹路径。")
        return

    for old_name, new_name in rename_map.items():
        old_path = os.path.join(folder_path, old_name)
        new_path = os.path.join(folder_path, new_name)

        if not os.path.exists(old_path):
            print(f"警告：文件 {old_name} 不存在，跳过。")
            continue



        try:
            os.replace(old_path, new_path)
            print(f"已将 {old_name} 重命名为 {new_name}")
        except Exception as e:
            print(f"错误：无法将 {old_name} 重命名为 {new_name}。原因：{e}")

if __name__ == "__main__":

    rename_files("output10")
