Case-insensitive globbing

Derek Chen-Becker dbecker at
Thu Jun 3 22:47:31 CEST 2004

Dennis Lee Bieber wrote:
> On 3 Jun 2004 09:59:36 -0700, tkpmep at (Thomas Philips)
> declaimed the following in comp.lang.python:
>>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.
> 	Unless XP has made a drastic change in the handling of file
> names, you don't worry about them...
>>>>flist = glob.glob("D*.*")
> ['desktop.ini', 'Dennis Lee Bieber.asc', 'Doc1.doc', 'DF297.pdf']

You can also make it cross platform by doing this:

flist = glob.glob("[dD]*.*")


More information about the Python-list mailing list