It is possible. Here's a way to do it:
Copy your script to the folder ~/.local/share/nautilus/scripts/
-- please note that this path will expand to include the current user information, such as: /home/john/.local/share/nautilus/scripts/
.
Now, on your script, capture the argument using $1
. For example, let's say that your script is intended to delete the file, then your script could be like this:
#!/bin/bash
rm -f "$1"
exit
Now, restart Nautilus
and navigate to the file you want to execute the action on. Right-click the file, and on the menu that appears, choose "scripts", and on the sumenu that appears, choose your script name -- that will execute your script with the file name as argument.
Note: don't forget to make your script executable first, for example: chmod +x /home/john/.local/share/nautilus/scripts/myScript