title: How to create a Python nested dictionary based on a FTP tree of folders
body: <p>I'm trying to create a dictionary based on a tree of folders located on a FTP server (see image below):</p>
  <p><a href="https://i.stack.imgur.com/CdjG8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CdjG8.png" alt="enter image description here" /></a></p>
  <p>The result I'm looking for is : A primary dictionnary that have secondary dictionnaries (as keys) with some lists (as values).</p>
  <pre><code>rootpath = r'C:\Users\_M92\Desktop\myFolder'
  
  dict = {'subfolder1': ['sub-subfolder1', 'sub-subfolder2', 'sub-subfolder3']}, \
         {'subfolder2': ['sub-subfolder1']}, \
         {'subfolder3': ['sub-subfolder1', 'sub-subfolder2']}
  </code></pre>
  <p>I have to precise that the sub-subfolders can eventually have some folders within.<br />
  Do you have any suggestions how to reach this kind of operations, please ?</p>
  <h3>EDIT :</h3>
  <p>With @Elmatador DeAngel's suggestion/answer <a href="https://stackoverflow.com/a/73353386/19603419">here</a>, we get close enough :</p>
  <pre><code>dict = {'subfolder1': {'sub-subfolder1': 'Empty', 'sub-subfolder2': 'Empty', 'sub-subfolder3': 'Empty'},\
          'subfolder2': {'sub-subfolder1': 'Empty'},  \
          'subfolder3': {'sub-subfolder1': 'Empty', 'sub-subfolder2': 'Empty'}}
  </code></pre>