title: Renaming file names containing spaces
body: <p>I am writing a simple Python script to rename all files in a directory to replace all spaces in the file name with hyphens.  I have the following which is crashing on os.rename</p>
  
  <pre><code>import os
  
  path =  os.getcwd()
  filenames = os.listdir(path)
  
  for filename in filenames:
      os.rename(os.path.join(path + filename), os.path.join(path + filename.replace(" ", "-")))
  </code></pre>
  
  <p>Gives the error in the console:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 2, in &lt;module&gt;
  OSError: [Errno 2] No such file or directory
  </code></pre>
  
  <p>Any ideas on why this is happening?</p>