Program that can find a find a file for you ?

Steve lonetwin at gmail.com
Wed Sep 29 16:24:33 CEST 2004


Hi Peter,

On Wed, 29 Sep 2004 11:25:39 +0200, Peter Hansen <helten0007 at yahoo.com> wrote:
> Im trying to write a program that can be run from the command line.
> If I want to search for example after a file with the ending .pdf, I should
> be able to write in the command line:
> python  name of my program / the libary to search and what kind of file it
> is example a .pdf file

I had to do something like this sometime back so I wrote up a general
purpose script that would look for certain types of files and call a
python function, passing the filename as argument to the function.
This function could be any thing that you would care to define (My
script incidentally just rename file with *ill formed* names). This is
roughly the equivalent doing this using the 'find' unix command:

 $ find -name "*.ext" -exec (some python function) {} ';'

You can find the function at the ASPN cookbook site:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/300411

Hope you find it useful.

Regards
Steve



More information about the Python-list mailing list