parsing directory for certain filetypes

royG roygeorget at gmail.com
Tue Mar 11 01:21:48 EDT 2008


On Mar 10, 8:03 pm, Tim Chase  wrote:

> In Python2.5 (or 2.4 if you implement the any() function, ripped
> from the docs[1]), this could be rewritten to be a little more
> flexible...something like this (untested):
>

that was quite a good lesson for a beginner like me..
thanks guys

in the version using glob()
>path = os.path.normpath(os.path.join(folder, '*.txt'))
>lst = glob.glob(path)

is it possible to check for more than one file extension? here i will
have to create two path variables like
path1 = os.path.normpath(os.path.join(folder, '*.txt'))
path2 = os.path.normpath(os.path.join(folder, '*.doc'))

and then use glob separately..
or is there another way?

RG



More information about the Python-list mailing list