import json import os def replace_flag_in_json(directory): for root, dirs, files in os.walk(directory): for file in files: if file.endswith('.json'): file_path = os.path.join(root, file) try: with open(file_path, 'r', encoding='utf-8') as f: content = f.read() if '"Test Tube Merchant":' in content: content = content.replace('"Test Tube Merchant":', '"test_tube_merchant":') with open(file_path, 'w', encoding='utf-8') as f: f.write(content) print(f'Updated: {file_path}') except Exception as e: print(f'Error processing {file_path}: {str(e)}') if __name__ == '__main__': items_dir = 'f:/work/foundry/v13data/Data/modules/test_tube_merchant/items' replace_flag_in_json(items_dir)