import json import os # Directory containing the JSON files directory = 'DemoFeedback' # Check each file in the directory for filename in os.listdir(directory): if filename.endswith('.json'): file_path = os.path.join(directory, filename) # Open and load the JSON file with open(file_path, 'r+') as file: data = json.load(file) # Check if 'revision' field is missing if 'revision' not in data: data['revision'] = 'N/A' # Move the file pointer to the beginning of the file file.seek(0) # Write the updated data json.dump(data, file, indent=4) # Truncate the file to the new data length file.truncate() print(f"Updated file: {filename}") print("Files have been checked and updated as needed.")