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:
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:
my_pics = winpaths.get_my_pictures()
my_docs = winpaths.get_my_documents()
You can install it using easy_install:
Here are the folders it provides access to:
get_local_appdata — Local App Data folder for current userget_appdata — App Data folder for current userget_desktop — Desktop folder for current userget_programs — Programs directory under Start menuget_admin_tools — Admin Tools directory under Start menuget_common_admin_tools — Start Menu -> Admin Toolsget_common_appdata Common App Data folderget_common_documents Common My Documents folderget_cookies — Cookies folder for current userget_history — Historyget_internet_cache — Internet cacheget_my_pictures — My Pictures folder for current userget_personal — My Documentsget_my_documents — alias for get_personalget_program_files — Program Files under root driveget_program_files_common — Program Files -> Common Filesget_system — Use care and discretionget_windows — Use care and discretionget_favorites — Favorites folder for current userget_startup — Startup folder under Start Menu -> Programsget_recent — Recent files for current user
[Update] — winpaths now has a permanent page here.

Very usefull… Thank you very much.
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?
Thanks for pointing that out, Morten. I’ve uploaded a new version of
).
winpathsthat supports pip (i.e., I renamed the setup file to “setup.py”