import os
import json

def create_file_list_json(directory):
    for root, dirs, files in os.walk(directory):
        if not dirs:
            json_files = [file for file in files if file.endswith(".json") and file != "list.json"]
            base_filenames = [file.replace(".json", "") for file in json_files] 
            file_lists = {
                "json_files": json_files,
                "base_filenames": base_filenames  
            }
            list_path = os.path.join(root, "list.json")
            with open(list_path, "w") as list_file:
                json.dump(file_lists, list_file, indent=4)

top_level_directory = "output"
create_file_list_json(top_level_directory)
