[python-win32] Try to got short path for files - but goterror...

Mark Hammond mhammond at skippinet.com.au
Thu May 25 03:15:28 CEST 2006


> Mark,
> 	Do you know if it's possible to get all the usual "right-click"
> file properties using win32com or ctypes?  I know Windows presents short
> names via properties, but wasn't sure that's exposed via either.  I
> googled this but didn't see a clear direction after the first 50 hits.
> May be a bad search on my part.

I believe all properties can be fetched fine, including 'extended'
properties via COM.

But I've lost the context here - 'clear direction' for what exactly?

eg, I created a long filename c:\temp\Copyright someone.txt and:

>>> win32api.GetShortPathName(u"c:\\temp\\\xa9opyright
someone.txt".encode("mbcs"))
'c:\\temp\\OPYRIG~1.TXT'
>>> open('c:\\temp\\OPYRIG~1.TXT')
<open file 'c:\temp\OPYRIG~1.TXT', mode 'r' at 0x008CF5E0>
>>>

It also dawned on me that the "short name" of a file should never contain
unicode characters!  That seems to be demonstrated above...

Mark



More information about the Python-win32 mailing list