import os
import re

directory = r"D:\Minrcraft Run1\versions\26.1.2-Fabric\resourcepacks\Featured 1.5\assets\minecraft\models\item"

for filename in os.listdir(directory):
    filepath = os.path.join(directory, filename)

    if not os.path.isfile(filepath):
        continue

    with open(filepath, "r", encoding="utf-8") as f:
        content = f.read()

    # 匹配 "xxx_darker/yyy" 的模式，将 _darker 移到 / 前面
    new_content = re.sub(r'(\w+)/([\w]+)(_darker)', r'\1\3/\2', content)

    if new_content == content:
        print(f"无需替换: {filename}")
        continue

    with open(filepath, "w", encoding="utf-8") as f:
        f.write(new_content)

    print(f"已处理: {filename}")

print("\n全部完成！")