Short form of file names
Mark Hammond
MarkH at ActiveState.com
Fri Jul 6 21:38:06 EDT 2001
Mikhail Astafiev wrote:
> [Env: Win2k, Win98, Python 1.52]
>
> Hi!
>
> Is there some Python module for converting Windows long paths to short
> form, i.e. 8.3? os.path.normpath() does not do this..
>
>>> win32api.FindFiles("F:\\Program Files")[0][9]
'PROGRA~1'
>>>
[0] is the index into the list of filenames (only 1 in this case). Each
file has a tuple of information about the file - element 9 is the short
name.
Note that the returned value does _not_ include the path component.
Thus, to get a short name of the directory structure too, each directly
must be checked manually.
Later versions of Windows have a GetShortPathName() (or something like
that) but it is not in win32api yet.
Mark.
More information about the Python-list
mailing list