Skip to content

Instantly share code, notes, and snippets.

View a-berg's full-sized avatar
🏠
Working from home

a-berg

🏠
Working from home
View GitHub Profile
@a-berg
a-berg / GPT-4 prompt
Created March 18, 2023 13:36
directory crawler & dirtree formatter, generated by GPT-4
You have to write a python script that:
1. Recursively crawls a directory, creating a nested dictionary representing the file and folder structure, with the first key being said directory.
2. The recursion could have a limit, like the standard `tree` bash command.
3. Using a recursive funcion is not a must, you could use a `while` loop if it helps performance and readability, or be creative with `dict` merging and splitting paths.
3. accepts a directory as an input
4. accepts a level optional argument to limit
5. accepts an optional alias for the input directory
6. uses pathlib for path related functions and argparse for argument parsing
Example: for a folder named "myfolder/" with the following structure: