At work we sometimes need to set up project folders with many subfolders, we try to keep them all consistent and so I'm trying to automate it. I want to be able to specify a folder structure and how many instances I want, and then see a preview of the finished file structure. Right now I can create a folder class and put other folder classes into it as subfolders:
class Folder:
def __init__(self, name, level, subfolders):
self.name = name
self.level = level # not sure I actually need this, was trying to keep track of how deep the folder is
self.subfolders = subfolders # this is just other class instances
Now for example, lets say I had a folder called "New Project", it's subfolders / classes were "CAD", "Admin", and "Client Data", and then "CAD" had a subfolder / class called "Old". I would want my text preview in the GUI to look like this:
My Project
CAD
Old
Admin
Client Data
Where I'm stuck is I am having a hard time wrapping my head around what the loop needs to look like to go through all the class instances and get the structure to preview and then build correctly. I've tried a couple while loops but they keep becoming super complex with counters and lists to keep track of where I am and it just gets unmanageable, has anybody got any ideas or pointers for a scenario like this?