I'd like to take a single folder path (root) and then put all the file paths into a dictionary that resembles the original directory structure.
Ex: I have a folder that looks like this:
root
-sub1
--someFile.txt
--someFile2.txt
-sub2
--subsub1
---veryNested.txt
--someFile3.txt
-someFile4.txt
I would like the dictionary to look like this:
{'root': {
'.dirs': {
'sub1':{
'.dirs':{},
'.files':['someFile.txt', 'someFile2.txt']
},
'sub2':{
'.dirs':{
'subsub1':{
'.dirs':{},
'.files':['veryNested.txt']
}
},
'.files':['someFile3.txt']
}
},
'.files':['someFile4.txt']
}
I've been looking around and I can't really find a good general answer to this problem. Could someone point me towards some good resources, or give a brief and general explanation on what the code would look like? I'd like to figure this out without someone holding my hand 100% of the way, or just giving me the solution. Please let me know if more clarification is needed!