from config import *
import json
import os
from util import *

metadata = []
JSON_FILE_PATHS = []
      
def combineJSONInToOneArray(FILE_PATHS):
    metadata = []
    for json_path in FILE_PATHS:
        with open(json_path) as input:
            data = json.load(input)
            metadata.append(data)
    return metadata

def merge():
    JSON_FILE_PATHS = findAllFilesFromBasePath(NEW_ETDs_UPLOAD_PATH, "json")
    metadata = combineJSONInToOneArray(JSON_FILE_PATHS)
    with open(METADATA_JSON_FILE_PATH, 'w') as output:
        json.dump(metadata, output, indent=4)

if __name__ == "__main__":
        merge()
