Created
October 15, 2023 23:52
Revisions
-
Adam-S-Amir created this gist
Oct 15, 2023 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ # This file is made to create a JSON with the current folder's # file's in a file tree that look like this: # "Images": { # "Apple.png": null, # "Banana.png": null, # "Orange.png": null, # "Grape.png": null, # "Blueberry.png": null # } import os import json def generate_dir_structure(path): result = {} for item in os.listdir(path): item_path = os.path.join(path, item) if os.path.isdir(item_path): result[item] = generate_dir_structure(item_path) else: result[item] = None return result current_directory = os.getcwd() dir_structure = generate_dir_structure(current_directory) json_structure = json.dumps(dir_structure, indent=2) print(json_structure) f = open("file-tree.json", "w") f.write(json_structure) f.close()