I wrote the following code for searching a file on your computer:
import os, sys
import win32api
x=raw_input("Enter file name: ")
drives = win32api.GetLogicalDriveStrings()
drives = drives.split('\000')[:-1]
for drive in drives:
for folderName, subfolders, filenames in os.walk(drive):
for filename in filenames:
if x.upper() in filename:
print"FILE FOUND!"
print('FILE INSIDE ' + folderName + ': '+ filename)
elif x.lower() in filename:
print"FILE FOUND!"
print('FILE INSIDE ' + folderName + ': '+ filename)
elif x.capitalize() in filename:
print"FILE FOUND!"
print('FILE INSIDE ' + folderName +': '+ filename)
a=raw_input("Press any key to exit.")
sys.exit()
As you may have noticed this program is not fast enough.
So could anyone help me make a faster and more efficient version of this program?
Thanks!