Python Forum
Make nested system directories based on an unsorted list?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Make nested system directories based on an unsorted list?
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Organization of project directories wotoko 3 363 Mar-02-2024, 03:34 PM
Last Post: Larz60+
  unable to remove all elements from list based on a condition sg_python 3 373 Jan-27-2024, 04:03 PM
Last Post: deanhystad
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 1,258 May-22-2023, 10:39 PM
Last Post: ICanIBB
  List all possibilities of a nested-list by flattened lists sparkt 1 878 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Listing directories (as a text file) kiwi99 1 802 Feb-17-2023, 12:58 PM
Last Post: Larz60+
  Find duplicate files in multiple directories Pavel_47 9 2,926 Dec-27-2022, 04:47 PM
Last Post: deanhystad
  help me to make my password list in python >>> Oktay34riza 0 552 Dec-23-2022, 12:38 PM
Last Post: Oktay34riza
  rename same file names in different directories elnk 0 680 Nov-04-2022, 05:23 PM
Last Post: elnk
  select Eof extension files based on text list of filenames with if condition RolanRoll 1 1,475 Apr-04-2022, 09:29 PM
Last Post: Larz60+
  Updating nested dict list keys tbaror 2 1,243 Feb-09-2022, 09:37 AM
Last Post: tbaror

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020