How to get the filename in the right case ?

Stef Mientki stef.mientki at gmail.com
Thu Sep 25 21:38:56 CEST 2008


I found a partial workaround that is good enough for me:

def Get_Windows_Filename ( FileName ) :
  if os.name == 'nt' :
    File = os.path.splitext ( FileName .lower ())[0]
    return glob.glob ( File + '.p?' )
  return FileName

This will translate the filename into the correct case, but not the path.

I also looked at os.path.walk, but that's too slow for me,
because getting the path correct means I have to start at the root.

cheers,
Stef



More information about the Python-list mailing list