title: Python script to count number of files in a folder based on matching string within the files
body: <p>I have a folder containing multiple files. I want to count the number of files that contains matching text say "Pathology" or a pattern say "ORC|||||xxxxxxxx||||||" inside it from those files present inside the folder. I have tried following scripts :</p>
  
  <pre><code>import re, os
  import glob
  
  list_of_files = glob.glob('./*.hl7')
  
  for fileName in list_of_files:
      fin = open( fileName, "r" )
      count = 0
  
  for line in fin:
      if re.match("Pathology", line):
              count +=1
  fin.close()
  
  print count
  </code></pre>
  
  <p>This gives me result as 0. I am using python 2.6.6. and have no options of upgrading my python. Please suggest a way to do this.</p>