title: Creating writeable directory in Windows using Python os.makedirs
body: <p>I need to create a subdirectory if it doesn't yet exist, then copy some files into it. However, whenever I try, I get a Permission denied error. I've tried chmod, with 777 as well as stat.S_IWRITE, I've tried os.system('attrib -r), but nothing works. Can anyone help me work this one out? I know there is a similar question on the site, but it says to use chmod, which isn't working for me.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>beginpath = "C:\Users\foo"
  fullpath = os.path.join(beginpath, foldername)
  print fullpath
  fullpath = fullpath.replace('\n', '')
  
  ##create a folder to hold the deleted files
  deleted = os.path.join(fullpath, "Deleted")
  print deleted
  if not os.path.exists(deleted):
              os.makedirs(deleted)
              os.chmod(deleted, stat.S_IWRITE)
              print "created"
  
  
  
  ##do some other processing here
  
  
  oldfile = os.path.join(fullpath, newpagename)
  shutil.copyfile(oldfile, deleted)
  </code></pre>