title: How to read all files in one folder and apply a function over them in python?
body: <p>I would like to run a function over all files in one folder and create new files out of them. I have put the code for one file bellow. I would appreciate it if you kindly help me.</p>
  
  <pre><code>def newfield2(infile,outfile):
      output = ["%s\t%s" %(item.strip(),2) for item in infile]
      outfile.write("\n".join(output))
      outfile.close()
      return outfile
  
  
  infile = open("E:/SAGA/data/2006last/325125401.all","r")
  outfile = open("E:/SAGA/data/2006last/325125401_edit.all","r")
  </code></pre>
  
  <p>I would like to change all the files in the 'E:/SAGA/data/2006last/' folder and create new files with edit extension.</p>