hanzo/scripts/concatFiles.py
2024-04-08 12:30:31 +02:00

29 lines
668 B
Python

import os
import json
# Directory path
directory = './'
# Output file path
output_file = './concat.js'
# List to store JSON data
json_data = []
# Iterate over files in the directory
for filename in os.listdir(directory):
if filename.endswith('.json'):
file_path = os.path.join(directory, filename)
try:
with open(file_path, 'r') as file:
data = json.load(file)
if data.get('type') == 'spell':
json_data.append(data)
except Exception as e:
print(f"Error reading file {file_path}: {str(e)}")
# Write the concatenated JSON data to the output file
with open(output_file, 'w') as file:
json.dump(json_data, file)