import json
import os

# Verzeichnis mit den übersetzten Dateien
input_directory = "actors_split_translated"
output_file = "wfrp4e-eis-actors-merged.json"

# Alle übersetzten Dateien finden
merged_actors = {}
for file_name in os.listdir(input_directory):
    if file_name.endswith(".json"):
        file_path = os.path.join(input_directory, file_name)
        with open(file_path, 'r', encoding='utf-8') as file:
            data = json.load(file)
            merged_actors.update(data)

# Gesamte Datei speichern
with open(output_file, 'w', encoding='utf-8') as out_file:
    json.dump(merged_actors, out_file, ensure_ascii=False, indent=4)

print(f"{len(merged_actors)} Einträge erfolgreich zusammengeführt.")
