交错战线修改

写了个脚本,能批量修改成可以解包的形式,代码贴这里了

import os
def remove_content_before_second_unityfs(path):
    try:
        for root, dir, files in os.walk(path):
            if "disabled" in root.lower():
                continue
            for file in files:
                if "disabled" in file.lower() :
                    continue
                # 以二进制读取模式打开文件
                file_path = os.path.join(root, file)
                with open(file_path, 'rb') as file:
                    content = file.read()
                print(file_path)
                # 寻找所有“UnityFS”出现的位置
                marker = b'UnityFS'
                positions = [i for i in range(len(content)) if content.startswith(marker, i)]

                # 检查是否找到至少两个“UnityFS”
                if len(positions) < 2:
                    print("未找到足够的'UnityFS'标记。")
                    continue

                # 第二个“UnityFS”的位置
                second_unityfs_pos = positions[1]

                # 保留第二个“UnityFS”及其后的内容
                new_content = content[second_unityfs_pos:]

                # 以二进制写入模式打开文件并覆盖内容
                with open(file_path, 'wb') as file:
                    file.write(new_content)

                print("文件修改成功。")

    except IOError as e:
        print(f"文件操作失败: {e}")
        

# 使用示例
path = '.\\Custom'  # 替换为你的文件路径
remove_content_before_second_unityfs(path)
os.system('pause')
4 个赞