title: run python code on a folder of files at once
body: <p>I have a script that extracts data elements from XML files. I would like to run this on a directory(folder) of XMLs rather than a single one. This is what I have so far: <br></p>
  
  <pre><code>from xml.dom import minidom
  from datetime import *
  import os
  import glob
  
  filename = glob.glob("*.xml")
  f = open(filename)
  for xml in f:
      print (xml)
      xmldoc = minidom.parse(xml)
      tcd = xmldoc.getElementsByTagName("QualityMeasureDocument")[0]
      sport = activitiesElement.attributes["root"]
      sportName = sport.value
      print (sportName)
  </code></pre>
  
  <p><br></p>
  
  <p>I am getting this error: <br></p>
  
  <pre><code>Traceback (most recent call last):
  File "C:/Python34/Scripts/process.py", line 7, in &lt;module&gt;
  f = open(filename)
  TypeError: invalid file: ['CMS9v2.xml', 'country_data.xml', 'test.xml']
  activitiesElement = tcd.getElementsByTagName("id")[0]
  </code></pre>
  
  <p><br></p>
  
  <p>It would be nice to make this into a function as well.</p>