Python Forum
Make nested system directories based on an unsorted list? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Make nested system directories based on an unsorted list? (/thread-25273.html)



Make nested system directories based on an unsorted list? - koebi - Mar-25-2020

Hello,

I am looking for a solution that I can make nested directories based on an unsorted list.

Here is a simplified example:

Input:
unsorted_list = ['Abb', 'B', 'Ab', 'Aba', 'Ba 2', 'Ba 1', 'C', 'A', 'Abc', 'Ac', 'Ba', 'Ba 11']

Output:
.
├── A
│   ├── Ab
│   │   ├── Abe
│   │   └── Aby
│   └── Ad
├── B
│   └── Be
│   ├── Bee 1
│   │   └── Bee 11
│   └── Bee 2
└── C


The tree shows the desired directory structure to be created in the file system.

Thanks a lot for your ideas!

Kind regards,

koebi