Help search files

Mariano Mara mmara at fibertel.com.ar
Wed Jul 4 15:27:34 EDT 2007


Alejandro Decchi escribió:
> Hello Someone can help me how to search file in a directory. I need to 
> do a form where the user write the word to search and if the file was 
> found the user must could download the file making click in the link
> Sorry my english
> thz
> Alex
> 
You could try os.walk (search for "walk" here: 
http://docs.python.org/lib/os-file-dir.html) and then loop the results 
to find the file (sure there are some out of the box methods for this 
but right now I don't know any).
One thing I'm not sure if you want to search for a word within the file 
or if the submitted word matches the name of the file. My suggestion 
should work for the last option.

Good luck.






More information about the Python-list mailing list