import os
import shutil

def replace_json_files(folder_path, new_json_path):
    # Ensure the folder path ends with a backslash
    if not folder_path.endswith('\\'):
        folder_path += '\\'
    
    # Iterate through all files in the folder
    for filename in os.listdir(folder_path):
        # Check if the file is a json file
        if filename.endswith('.json'):
            file_path = os.path.join(folder_path, filename)
            
            # Remove the existing json file
            os.remove(file_path)
            
            # Copy the new json file to the same location with the original file name
            shutil.copy(new_json_path, file_path)
            
    print("All json files have been replaced.")

# Example usage:
folder_path = r'C:\Users\rbecu\AppData\Roaming\.modrinth\profiles\Main\saves\Into the Bungeon\datapacks\Bungeon\data\minecraft\worldgen\structure'
new_json_path = r'C:\Users\rbecu\AppData\Roaming\.modrinth\profiles\Main\saves\Into the Bungeon\datapacks\Bungeon\data\minecraft\worldgen\ancient_city.json'

replace_json_files(folder_path, new_json_path)