An example how to find a file (Windows7):
# search for a filename in a given directory
# and all its subdirectories
# tested with Python27 and Python33
import os
def find_file(folder, filename):
"""
search for a filename starting in directory/folder
and then its subdirectories, return full path name or None
"""
for root, dirs, files in os.walk(folder):
#print(dirs)
for fname in files:
# make search case insensitive
if fname.lower() == filename.lower():
return os.path.join(root, fname)
return None
# file to search for
filename = "i_view32.exe"
# directory/folder to start search
folder = r"C:\Program Files (x86)"
result = find_file(folder, filename)
if result:
print("File found --> %s" % result)
else:
print("File %s not found" % filename)