By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,095 Members | 1,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,095 IT Pros & Developers. It's quick & easy.

"Show this file in explorer"

rodmena
P: 1
I have a big problem. I have a list of files that my script find and
list them in a little gui.
I need this function:

when i d-click on each item, I want explorer opens and selects that
item inside windows explorer.
like that beautiful buttom in iTunes.
what is that trick?


Thanks in advane.

Farshid Ashouri.
Dec 1 '07 #1
Share this Question
Share on Google+
2 Replies


P: 75
I have a big problem. I have a list of files that my script find and
list them in a little gui.
I need this function:

when i d-click on each item, I want explorer opens and selects that
item inside windows explorer.
like that beautiful buttom in iTunes.
what is that trick?


Thanks in advane.

Farshid Ashouri.
Expand|Select|Wrap|Line Numbers
  1. import os
  2. os.system("c:/windows/explorer.exe")
  3.  
this opens the exlorer

you must know the file path/file name in your application which you want to show in explorer, when you have made that code, use

os.system("c:/windows/explorer.exe /select,c:\test.txt")

this would now open explorer and select "test.txt"

I would prefer to use /n option also...
os.system("c:/windows/explorer.exe /n,/select,c:\test.txt")

now it removes that nasty file tree view from the left ^^

more info about windows explorer.exe http://support.microsoft.com/kb/130510

ofcourse this isn't the perfect solution, because windows folder must be at c:/windows for this to work... I think that you can check where's your windows folder using os module, but I'm not sure
Dec 3 '07 #2

P: 75
a little better version

Expand|Select|Wrap|Line Numbers
  1. import os
  2. os.system("%SYSTEMROOT%/explorer.exe /n,/select,c:\test.txt")
  3.  
so now %SYSTEMROOT% points out always to windows folder, despite wherever place the windows folder is

some info about environment variables http://vlaurie.com/computers2/Articles/environment.htm
Dec 3 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.