Finding file names (from a directory) in a file
<p>I want to find if all the files of a certain type have been logged by my program. So essentially, I have a logfile with just the file names and then I use a function to run through the file to check if the file is present. Now the contents are huge but I did this in a crude way. Unfortunately, it's not working properly. </p>

<pre><code>import subprocess
import sys
import signal
import shutil
import os, fnmatch


#open file to read
f=open("logs", "r") #files are stored in this directory
o=open("all_output_logs","w")
e=open("missing_logs",'w')


def locate(pattern, root=os.curdir):
    '''Locate all files matching supplied filename pattern in and below
    supplied root directory.'''
        #ignore directories- ignore works, just uncomment. 
    #ignored = ["0201", "0306"]
    for path, dirs, files in os.walk(os.path.abspath(root)):
        #for dir in ignored:
           # if dir in dirs: 
                #dirs.remove(dir)
        for filename in fnmatch.filter(files, pattern):
            yield os.path.join(path, filename)



    #here i log all the files in the output file to search in
for line in f:
    if line.startswith("D:"):
        filename = line
        #print line
        o.write(filename)

f.close()
o.close()
r.close()

i=open("all_output_logs","r")
#primitive search.. going through each file in the directory to see if its there in  the log file
for filename in locate("*.dll"):
    for line in i:
        if filename in i:
            count=count+1
            print count
        else:
            e.write(filename)
</code></pre>

<p>I do not see my dummy variable count being printed, and I only get one filename which is somehow in the middle of the list.</p>
