title: How can I rename sub-directories -- normal way doesn't seem to work
body: <p>So I <em>thought</em> I understood well how to do this but it isn't working and I'm hoping some here will have an idea on where I might be going wrong.</p>
  
  <pre><code>for root, dirs, files in os.walk(maindir):
      path = root.split(os.sep)
          if os.path.basename(root).find(".") &gt; -1: #we find dot numbers
              print (root)
              holdlen = root.find(".")
              holdp = root[:holdlen] + "__material"
              print (holdp)
              os.rename(root,holdp)
  </code></pre>
  
  <p>I'm looking to rename folders that have this sort of spec:</p>
  
  <p>V:\myfolder\mymaterial.003__material</p>
  
  <p>to:</p>
  
  <p>V:\myfolder\mymaterial__material</p>
  
  <p>I can do this manually (so it's not a case of, say, the folder already existing or some other element being wrong) and the printout says it's correct (which is to say it shows the name previous and then the correct name to rename) but while it doesn't throw any errors it also doesn't rename the folder.</p>
  
  <p>I'm stumped -- don't even know what to try now.  Any clues?</p>