Retrieving common Windows folder names with Python

Often using Windows, you'll need to get the names of special folders, like "App Data," "Local App Data," "My Documents," and "My Pictures." This is especially true in Vista, where the recommended practice of writing app-specific data to the (Local) App Data directory is being enforced.

You can do this using the win32com.shell.shell module in the pywin32 module:

from win32com.shellimport shell, shellcon

my_pics = shell.SHGetFolderPath(0,
shellcon.CSIDL_MYPICTURES,0,0)

In addition, I've written a simple module that does this. It depends only on ctypes, and provides a simpler interface to the Windows shell API. Usage:

5 comments to Retrieving common Windows folder names with Python

I was all set to use this, but found out that the package on pypi isn’t “pip-compatible”, for the simple reason that instead of naming the setup-script “setup.py”, you have named it “setup_winpaths.py”. Any chance you could rename the file and upload a version 0.2 to pypi? 🙂