title: Python os.rename and os.walk together
body: <p>I just wrote a python script to get rid of some annoying suffixes in filenames,</p>
  
  <p>here's my code:</p>
  
  <pre><code>import os
  
  for root, dirs, files in os.walk("path"):
  
      for filename in files:
  
          if filename.endswith("[AnnoyingTag].mov"):
  
              os.rename(filename, filename[:-18]+'.mov')
  </code></pre>
  
  <p>but I got the error in the last line:</p>
  
  <pre><code>OSError: [Errno 2] No such file or directory
  </code></pre>
  
  <p>I am pretty sure that I have the right path because I can print out all filenames correctly.</p>
  
  <p>...really have no idea why this can't work.</p>
  
  <p>Thanks for your answers</p>