title: Change the file extension for files in a folder?
body: <p>I would like to change the extension of the files in specific folder. i read about this topic in the forum. using does ideas, I have written following code and I expect that it would work but it does not. I would be thankful for any guidance to find my mistake. </p>
  
  <pre><code>   import os,sys
     folder = 'E:/.../1936342-G/test'
     for filename in os.listdir(folder):
             infilename = os.path.join(folder,filename)
             if not os.path.isfile(infilename): continue
             oldbase = os.path.splitext(filename)
             infile= open(infilename, 'r')
             newname = infilename.replace('.grf', '.las')
             output = os.rename(infilename, newname)
             outfile = open(output,'w')
  </code></pre>