EvilZone

Programming and Scripting => Scripting Languages => : Clone February 02, 2014, 09:11:19 PM

: python File Searcher
: Clone February 02, 2014, 09:11:19 PM
This is a python script to search for files and directories in root.Its kinda slow i was hoping for corrections
: (Python)
import os
count=0
print"File Searcher"
print"---------------------------------------------------------------"
print"---------------------------------------------------------------"
filename=raw_input("Enter file name to be searched:")
print"Searching for %s..."% filename
for rootDir,dirs,files in os.walk("/"):
    for Dir in dirs:
        if Dir.endswith(filename):
            print count,".)PATH:",rootDir+"//"+Dir
            count=count+1
    for fileX in files:
        if fileX.endswith(filename):
            print count,".)PATH:",rootDir+"//"+fileX
            count=count+1
count=count-1           
print"End of search."
if count<=0:
    print"No results matching \"%s\" found"% filename
else:   
    print"No of results found matching \"%s\"is %d"% (filename,count)
: Re: python File Searcher
: Phage February 03, 2014, 08:19:29 AM
I don't really see the purpose for this tool, sorry. Pretty much all OS's has a feature like this built in.
: Re: python File Searcher
: kenjoe41 February 03, 2014, 09:22:08 AM
No problem if it is a learning project or can be use in another script for instance where you hate to call the system's Find.