Python utility convert Windows long file name into 8.3 DOS format

vincent wehren vincent at visualtrans.de
Thu Oct 28 04:55:16 EDT 2004


Simon Brunning wrote:
> On Thu, 28 Oct 2004 06:47:28 GMT, Ben Kial <benkial at hotmail.com> wrote:
> 
>>Is there a Python program to convert Windows long filename, like "c:\Program
>>Files" into the old DOS 8.3 format, like "c:\Progra~1"?
> 
> 
>>>>import win32api
>>>>win32api.GetShortPathName('D:/share/from_roadwarrior/simon/python/RandomizeScreenSaver/RandomizeScreenSaver.pyw')
> 
> 'D:/share/FROM_R~1/simon/python/RANDOM~1/RANDOM~1.PYW'
> 

Just note that GetShortPathName expects a valid and accessible path in 
your file system.

--
Vincent Wehren



More information about the Python-list mailing list