title: Python: Finding user id and moving directories (Windows)
body: <p>What I'm trying to accomplish is to have my program move itself from the folder it's currently in, to another folder. In this case, Videos. This is the code:</p>
  
  <pre><code>import getpass
  import os
  
  userid = getpass.getuser()
  
  
  print os.getcwd()
  
  os.rename("$s/userid.py", "%s/Videos/userid.py")  % ('os.getcwd()', '%userid')
  </code></pre>
  
  <p>But running it from power shell gets me this error: </p>
  
  <pre><code>Traceback (most recent call last):
  File "userid.py", line 9, in &lt;module&gt;
  os.rename("$s/userid.py", "%s/Videos/userid.py")  % ('os.getcwd
  WindowsError: [Error 3] The system cannot find the path specified
  </code></pre>
  
  <p>And then I thought maybe the parentheses with os.getcwd() was causing problems so I tried this but with the same error:</p>
  
  <pre><code>import getpass
  import os
  import shutil
  
  userid = getpass.getuser()
  
  
  currentpath = os.getcwd()
  
  shutil.move("%s/userid.py", "C:/users/%s/Videos/userid.py")  % (currentpath, userid)
  </code></pre>
  
  <p>Also, if I don't just want the current user's id, but the id for all users profile, how would I do that?</p>
  
  <p>Thanks</p>
  
  <p>UPDATED: It works! Thanks so much everyone</p>
  
  <pre><code>import getpass
  import os
  import shutil
  
  
  currentpath = os.path.abspath(os.path.dirname(__file__))
  
  
  shutil.copyfile("%s/userid.py" % currentpath, "%s/Videos/userid.py" % os.path.expanduser('~'))
  </code></pre>