• 注册
  • 一般交流 一般交流 关注:5875 内容:8959

    有没有不用一个个文件地这么点开就能快速查​mod物品ID的办法

  • 查看作者
  • 打赏作者
  • 当前位置: ODDBA社区 > 离线版交流区 > 一般交流 > 正文
  • 2
  • 一般交流
  • 初窥堂奥

    mod物品ID冲突了,一个个找太折磨了

    炉火纯青
    VIP3
    2021

    用notepad搜索文件夹

    回复
    初窥堂奥

    使用有全类型文件搜索的程序,比如楼上提到过notepad++,我自己是用的python脚本,你如果会用python可以用这个。

    import os
    
    def read_file_with_multiple_encodings(file_path, encodings):
        for encoding in encodings:
            try:
                with open(file_path, 'r', encoding=encoding) as f:
                    return f.read()
            except Exception as e:
                print(f'尝试使用 {encoding} 读取 {file_path} 失败: {e}')
        print(f'无法正常打开 {file_path}')
        return None
    
    def search_files(directory, suffix, target_string):
        encodings = ['utf-8', 'ansi', 'ISO-8859-1']  # 常见编码格式
        target_string_lower = target_string.lower()  # 处理大小写兼容
        for root, dirs, files in os.walk(directory):
            for file in files:
                if any(file.endswith(form) for form in suffix):
                    file_path = os.path.join(root, file)
                    # 检查文件名是否包含目标字符串(大小写兼容)
                    if target_string_lower in file.lower():
                        print(f'文件名包含: {file_path}')
                    else:
                        content = read_file_with_multiple_encodings(file_path, encodings)
                        if content and target_string_lower in content.lower():
                            print(f'内容中包含: {file_path}')
    
    # 设置需要查找的文件格式
    suffix = ['.txt', '.json', '.ini', '.jsonc', '.ts', '.js']
    
    # 请求用户输入目标字符串
    target_string = input("要查找的字符串:")
    
    # 请求用户输入查找的目录位置
    user_input = input("要查找的目录位置(输入 0 以使用当前脚本所在目录):")
    current_directory = os.getcwd() if user_input == "0" else user_input
    
    # 执行文件搜索
    search_files(current_directory, suffix, target_string)


    回复

    请登录之后再进行评论

    登录
    离线版交流区
  • 今日 5
  • 内容 10498
  • 关注 5875
  • 聊天
    关注 0

    【招募】GRIFFIN TKF项目开工 期待你的加入 || 你是否想加入格里芬书写自己与人形的故事

  • 签到
  • 任务
  • 发布
  • 模式切换
  • 偏好设置
  • 帖子间隔 侧栏位置: