title: Create folder tree dynamically from a string
body: <p>I am working on code in which I will create folders and sub folders based on a string retrieved from the database. It's dynamic; it could be one level, two levels, or ten.</p>
  
  <p>I'm trying to replace the dots with slashes and create the proper tree, but this code below won't do the job:</p>
  
  <pre><code>for x in i.publish_app.split('.'):
      if not os.path.isdir(os.path.join(settings.MEDIA_ROOT, PATH_CSS_DB_OUT) + x + '/'):
          os.mkdir(os.path.join(settings.MEDIA_ROOT, PATH_CSS_DB_OUT) + x + '/')
  </code></pre>
  
  <p><code>i.publish_app</code> is, for example, <code>'apps.name.name.another.name'</code>.</p>
  
  <p>How can I do it?</p>