Open Folder in Desktop
jimmy at retzlaff.com
Tue Jan 25 09:32:16 CET 2005
> Is there a command you can execute in Python that will open a window
> the desktop, such as 'My Documents'? Kind of like 'system', but for
> folder names, not just programs. I'm running on Windows 2000.
There are two issues here. The first is how to open a folder and the
second is how to resolve "special" folders. Folders are "documents"
typically associated with the explorer.exe application. To open a
document with its default app (e.g., a folder), use os.startfile which
is included in Python. For example:
Folders like My Documents, My Pictures, etc. are special and you need to
determine their actual path before you can open them. The pywin32
(https://sourceforge.net/project/showfiles.php?group_id=78018) include a
way to get at this:
from win32com.shell import shellcon, shell
path = shell.SHGetFolderPath(0, shellcon.CSIDL_MYPICTURES, 0, 0)
Google for CSIDL to find the constants to use for other special folders.
More information about the Python-list