2

I wrote MyScript.sh! MyScript.sh works great from the command line; it takes one or more file paths as its arguments.

In Ubuntu 18.10 how can I:

  1. After selecting one or more files in Nautilus/Files.
  2. Trigger MyScript.sh using the selected file/files as arguments?

I am happy to use either a contextual menu (i.e. right click), or a keyboard shortcut (.e. through Settings > Keyboard > Custom Shortcuts).

Unacceptable answer: I am not looking for someone to tell me to type ./MyScript.sh in the command in a terminal, and then drag-and-drop a file/files onto it from nautilus followed by <ENTER>.

Edit 1: I have tried placing MyScript.sh in ~/.local/share/nautilus/scripts/, ensuring it is executable, and right clicking on a file to apply, but no Script submenu appears.

Edit 2: I have set a Keyboard Shortcut in Settings > Keyboard, but the script does not execute.

Lexible
  • 1,557

1 Answers1

0

Run a script with files selected in Nautilus as argument

  1. Make sure MyScript.sh is executable.
  2. Copy (or move) the script to /home/$USER/.local/share/nautilus/scripts/.
  3. Open Nautilus and select a file (or multiple files).
  4. Right click on the selected file to open the context menu.
  5. Go to Scripts > MyScript.sh

enter image description here

Note: The Menu item Scripts > does not appear until there is a script or any file in the folder /home/$USER/.local/share/nautilus/scripts/. You can see the location of this folder in the top bar of the Nautilus screenshot above.

MyScript.sh will run with the selected files as arguments.

user68186
  • 37,461