Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Open Folder in Desktop
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Kamilche  
View profile  
 More options Jan 25 2005, 2:06 am
Newsgroups: comp.lang.python
From: "Kamilche" <klache...@comcast.net>
Date: 24 Jan 2005 23:06:58 -0800
Local: Tues, Jan 25 2005 2:06 am
Subject: Open Folder in Desktop
Is there a command you can execute in Python that will open a window on
the desktop, such as 'My Documents'? Kind of like 'system', but for
folder names, not just programs. I'm running on Windows 2000.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dennis Benzinger  
View profile  
 More options Jan 25 2005, 3:28 am
Newsgroups: comp.lang.python
From: Dennis Benzinger <Dennis.Benzin...@gmx.net>
Date: Tue, 25 Jan 2005 09:28:42 +0100
Local: Tues, Jan 25 2005 3:28 am
Subject: Re: Open Folder in Desktop

Kamilche wrote:
> Is there a command you can execute in Python that will open a window on
> the desktop, such as 'My Documents'? Kind of like 'system', but for
> folder names, not just programs. I'm running on Windows 2000.

Here are some commands you can use (tested on WinXP, so YMMV):

1. The os.system function

import os
os.system('explorer "c:\program files"')

This has the disadvantage that a cmd.exe windows is also opened,
because os.system executes the command in a subshell.

But using this approach the explorer starts in front of all other windows.

2. The os.startfile function

import os
os.startfile("C:\program files")

Using startfile doesn't open a cmd.exe window, but the folder window
is not started in front of the other windows

3. The subprocess.Popen function

import subprocess
subprocess.Popen('explorer "C:\program files"')

With subprocess.Popen no cmd.exe window is opened and the explorer
starts in front of the other windows.
But the subprocess module is new in Python 2.4.

Bye,
Dennis


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ulf Göransson  
View profile  
 More options Jan 25 2005, 3:26 am
Newsgroups: comp.lang.python
From: Ulf Göransson <u...@algonet.se>
Date: Tue, 25 Jan 2005 09:26:50 +0100
Local: Tues, Jan 25 2005 3:26 am
Subject: Re: Open Folder in Desktop

Kamilche wrote:
> Is there a command you can execute in Python that will open a window on
> the desktop, such as 'My Documents'? Kind of like 'system', but for
> folder names, not just programs. I'm running on Windows 2000.

Maybe this is good enough?

os.system("explorer " + folder_path)

/ug


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jimmy Retzlaff  
View profile  
 More options Jan 25 2005, 3:32 am
Newsgroups: comp.lang.python
From: "Jimmy Retzlaff" <ji...@retzlaff.com>
Date: Tue, 25 Jan 2005 00:32:16 -0800
Local: Tues, Jan 25 2005 3:32 am
Subject: RE: Open Folder in Desktop

Kamilche wrote:
> Is there a command you can execute in Python that will open a window
on
> 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:

import os
os.startfile(r'c:\windows')

Folders like My Documents, My Pictures, etc. are special and you need to
determine their actual path before you can open them. The pywin32
extensions
(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)
os.startfile(path)

Google for CSIDL to find the constants to use for other special folders.

Jimmy


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
vincent wehren  
View profile  
 More options Jan 25 2005, 3:09 pm
Newsgroups: comp.lang.python
From: vincent wehren <vinc...@visualtrans.de>
Date: Tue, 25 Jan 2005 21:09:31 +0100
Local: Tues, Jan 25 2005 3:09 pm
Subject: Re: Open Folder in Desktop

Jimmy Retzlaff wrote:
> Kamilche wrote:

<sipped>
> Folders like My Documents, My Pictures, etc. are special and you need to
> determine their actual path before you can open them. The pywin32
> extensions
> (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)
> os.startfile(path)

> Google for CSIDL to find the constants to use for other special folders.

Here's the exact link you'll need (warning, long url ahead ;)

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shel...

--

Vincent Wehren


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steve Holden  
View profile  
 More options Jan 25 2005, 9:21 pm
Newsgroups: comp.lang.python
From: Steve Holden <st...@holdenweb.com>
Date: Tue, 25 Jan 2005 21:21:17 -0500
Local: Tues, Jan 25 2005 9:21 pm
Subject: Re: Open Folder in Desktop

Kamilche wrote:
> Is there a command you can execute in Python that will open a window on
> the desktop, such as 'My Documents'? Kind of like 'system', but for
> folder names, not just programs. I'm running on Windows 2000.

os.system("start .")

works for me.

regards
  Steve
--
Steve Holden               http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC      +1 703 861 4237  +1 800 494 3119


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kamilche  
View profile  
 More options Jan 25 2005, 10:10 pm
Newsgroups: comp.lang.python
From: "Kamilche" <klache...@comcast.net>
Date: 25 Jan 2005 19:10:49 -0800
Local: Tues, Jan 25 2005 10:10 pm
Subject: Re: Open Folder in Desktop
Thanks, startfile worked great for me!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google