Getting correct file names under Windows
eric.brunel at pragmadev.com
Thu Feb 7 18:25:25 CET 2002
Windows case insensitivity striked again: I've got a Python/Tkinter program
that uses the new tk function named tk_chooseDirectory (new in Tk 8.3),
displaying a directory selection dialog. For some reason, this function
insists in returning the selected directory all uppercase. Unfortunately,
even if Windows does not care about case, we definetely don't want that: the
disk we work on is mounted from a Samba Unix - therefore case sensitive -
server, and we want to use the same file names on both environments.
So I tried to get the "real" file name, i.e. the one that is defined on
Unix, and the one I actually see in Windows Explorer or DOS windows. I
Does anybody know any way to get the "real" name of a file or directory
under Windows, i.e. the one that Explorer displays?
- eric -
PS: For those interested, during my tests, I stumbled on an "interesting"
If I issue at the DOS prompt something like:
it prints the correct directory name (C:\Python21), even if I typed it the
"wrong" way in the cd.
Now, if I do exactly the same thing via Python:
>>> import os
the result is 'C:\\PYTHON21'.
Even if I do an os.popen('cd', 'r').readline(), it returns the same thing!
And apparently, the case I use in the chdir is kinda "sticky":
This is *weird*!
More information about the Python-list