Case-insensitive globbing
Larry Bates
lbates at swamisoft.com
Thu Jun 3 13:28:09 EDT 2004
Just use os.path.normcase() on all of them.
import glob
import os
flist=glob.glob(mask)
flist=[os.path.normcase(f) for f in flist]
...
<insert your code here>
HTH,
Larry Bates
Syscon, Inc.
"Thomas Philips" <tkpmep at hotmail.com> wrote in message
news:b4a8ffb6.0406030859.197ec3b3 at posting.google.com...
> I'm using the function glob from module glob to obtain a list of all
> files in a directory that match a pattern. Unfortunately, some
> filenames are in upper case, others are in lower case and yet others
> are in mixed case. How can I do a case-insenstive glob that picks up
> all files that match a string regardless of case? If its any help, I'm
> running Python 2.3.4 under Windows XP.
>
> Thomas Philips
More information about the Python-list
mailing list