Open Containing File Folder

Just starting out? Need help? Post your questions and find answers here.
User avatar
marcoagpinto
Addict
Addict
Posts: 1076
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Open Containing File Folder

Post by marcoagpinto »

Heya,

I want to right-click on a tab and select to open the folder with the file associated to the tab (open folder with the file selected, or just open the file folder, whatever it is possible).

How do I make it cross-platform?

Thanks!
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Open Containing File Folder

Post by spikey »

On Windows:

Code: Select all

RunProgram("explorer.exe", "/SELECT," + #DQUOTE$ + File$ + #DQUOTE$, "")
and Mac:

Code: Select all

RunProgram("open", "-R " + #DQUOTE$ + File$ + #DQUOTE$, "")
Linux is more complicated because first you've got to work out which File manager is in use. Have a look at the procedure 'DetectFileManager()' in the file LinuxExtensions.pb in the IDE's repo, see https://github.com/fantaisie-software/p ... ensions.pb.
User avatar
marcoagpinto
Addict
Addict
Posts: 1076
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Open Containing File Folder

Post by marcoagpinto »

spikey wrote: Wed Oct 15, 2025 9:26 pm On Windows:

Code: Select all

RunProgram("explorer.exe", "/SELECT," + #DQUOTE$ + File$ + #DQUOTE$, "")
and Mac:

Code: Select all

RunProgram("open", "-R " + #DQUOTE$ + File$ + #DQUOTE$, "")
Linux is more complicated because first you've got to work out which File manager is in use. Have a look at the procedure 'DetectFileManager()' in the file LinuxExtensions.pb in the IDE's repo, see https://github.com/fantaisie-software/p ... ensions.pb.
Heya,

Thank you.

The Linux will take a lot of effort, I believe. :cry: :cry: :cry:
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 205
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: Open Containing File Folder

Post by moulder61 »

@marcoagpinto

I just tried this in Linux and it opens my default file manager. I have no idea how you incorporate that into a program to do what you want though?

RunProgram("exo-open", "--launch FileManager", "")

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
User avatar
marcoagpinto
Addict
Addict
Posts: 1076
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Open Containing File Folder

Post by marcoagpinto »

moulder61 wrote: Thu Oct 16, 2025 12:01 am @marcoagpinto

I just tried this in Linux and it opens my default file manager. I have no idea how you incorporate that into a program to do what you want though?

RunProgram("exo-open", "--launch FileManager", "")

Moulder.
Heya,

And the path is in the last

Code: Select all

""
?

Thanks!
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 205
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: Open Containing File Folder

Post by moulder61 »

@marcoagpinto

Maybe? I was just trying to work out how to get the default file manager to open in Linux. That code worked for me.

What the rest of your code needs to be, I have no idea? You have to work that bit out yourself. :shock:

I only ran that one line I suggested on it's own. I was just trying to point you in the right direction, hopefully :idea:

Looking at spikey's examples, maybe add + #DQUOTE$ + File$ + #DQUOTE$ to the second parameter. I'm just guessing at the moment. :?:

The help file says that the last parameter is the working directory. It's optional, but if you use the second parameter you also have to use the third, even if it's empty, else the RunProgram() command doesn't work, in my experience.

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
AZJIO
Addict
Addict
Posts: 2218
Joined: Sun May 14, 2017 1:48 am

Re: Open Containing File Folder

Post by AZJIO »

Linux

Code: Select all

RunProgram("xdg-open", Path$, "")
; RunProgram("xdg-open", FilePath$, GetPathPart(FilePath$))
I suggested adding this to the help.
User avatar
marcoagpinto
Addict
Addict
Posts: 1076
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: Open Containing File Folder

Post by marcoagpinto »

Thank you all!
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: Open Containing File Folder

Post by Piero »

spikey wrote: Wed Oct 15, 2025 9:26 pmMac:

Code: Select all

RunProgram("open", "-R " + #DQUOTE$ + File$ + #DQUOTE$, "")
Linux is more complicated
🫣🙄… """#DQUOTE$""" is NOT foolproof for Mac/Linux…
Post Reply