🐛 Generate file if it doesn't exist

Signed-off-by: Bjorn Lammers <bjorn@lammers.media>
This commit is contained in:
Bjorn Lammers 2024-10-20 12:13:29 +02:00 committed by GitHub
parent 478994e9cc
commit 16a4a8fd7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,6 +39,11 @@ if __name__ == "__main__":
print("Please provide at least one folder path.")
sys.exit(1)
# Check if 'tree.json' exists
if os.path.exists('tree.json'):
print("'tree.json' already exists. No file was created.")
sys.exit(0)
# Generate the combined folder tree for all specified paths
combined_folder_tree = generate_combined_tree(folder_paths)
@ -46,4 +51,4 @@ if __name__ == "__main__":
with open('tree.json', 'w') as f:
json.dump(combined_folder_tree, f, indent=4)
print("Folder tree successfully written to 'tree.json'.")
print("Folder tree successfully written to 'tree.json'.")