title: Renaming a file in python
body: <p>I am trying to rename a file named <code>output.txt</code> with timestamp in python but i am getting <strong>Error :</strong> </p>
  
  <pre><code>Traceback (most recent call last):
    File "D:/Python27/rename.py", line 10, in &lt;module&gt;
      os.rename('output.txt', newfile)
  WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect
  </code></pre>
  
  <p>My code is below :</p>
  
  <pre><code>import datetime
  import os
  
  dt = str(datetime.datetime.now())
  newtime =  ".".join(dt[0:19].split())
  newfile = 'output'+newtime+'.txt'
  
  os.rename('output.txt', newfile)
  </code></pre>