Python Forum

Full Version: Make nested system directories based on an unsorted list?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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