How to get long file system path from python on windows

This returns me a shortcut (DOS convention) (on Windows):

import tempfile tempDir = tempfile.mkdtemp() print tempDir Output >>> c:\users\admini~1\appdata\local\temp\tmpf76unv 

Pay attention to admini~1 .

How can I get / convert this to the full path? e.g. C: \ Users \ Admin \ AppData ...

+6
python windows path
source share
2 answers

Please try the following code (updated):

 from ctypes import create_unicode_buffer, windll BUFFER_SIZE = 500 buffer = create_unicode_buffer(BUFFER_SIZE) get_long_path_name = windll.kernel32.GetLongPathNameW get_long_path_name(unicode(short_path_name), buffer, BUFFER_SIZE) long_path_name = buffer.value 

Hope this helps. See http://mail.python.org/pipermail/python-win32/2008-January/006642.html

+9
source share
 tempDir = win32file.GetLongPathName(tempDir) 
+4
source share

All Articles