How do I open folders in the file manager with a shell script? (newbie question)

Wrote a script like so

thunar /home/Edammer/Documents/ /home/Edammer/Downloads/

tried also writing exo-open instead of thunar.

Both commands work just fine when I open the terminal and I type them in myself.

The .sh file is in /home/bin,
I’ve edited the file’s permissions with right click - allow this file to run as a program.
The .sh file’s name is in camelCase.

I have other scripts I use in the bin folder and they work just fine.

What am I doing wrong and what’s the cause of the problem?

( I would’ve posted this in “Newbie corner” if it still existed )

How do you execute your script?

As indicated by the previous poster it’s important to know how you want I execute your script. If you ant to asdociate this with a keybird shortcut I found it useful to run

xterm -e
Of course you can call the terminal of your choice, and dependent on the terminal you might need to spell out the path to the script. I did thus to call ranger via super + r.
But i admit it also took a lot of experimentation.

If I look at the given command inside the bash script, I would say that you are trying to open two Thunar windows, one at ~/Documents and another at ~/Downloads.

When you are in Thunar you can

  1. click on (select) Documents
  2. hold down the ctrl key
  3. select Downloads
  4. and then right click to get the context menu.
  5. From there, you can either select “Open in 2 New Tabs” or “Open in 2 New Windows”, or “Open With”.

Steps 3-5, could be replaced with a double click of Downloads. A dialog will be displayed with the text, “Are you sure you want to open all folders?”

But program-wise, something you create, I think you might find XFCE Custom Actions helpful.


Two questions:

  1. What are you seeing?

  2. Where are you trying to execute this script - from Thunar or from the command line (Terminal)?

    I have a custom action, which creates a Thunar context menu entry called, “Run Script”. It allows me to right click a script and select this menu item. The custom action command line is xfce4-terminal --hold --command=%f. I believe the default action for a script is edit. These actions are set this way to make sure a user doesn’t accidentally execute a script.

Interesting. I’ll give both that and what @stargazer said a shot and see what feels best.

I tried executing it by double clicking the shortcut I made on desktop,
and also tried double clicking the .sh file itself in  bin.

I’m still learning all this with shell scripting.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.