I normally put my scripts under my user directory called ~/.local/share/nautilus/scripts
. One such sample script is given below:
#!/bin/bash
## Variables: (Refer to: https://help.ubuntu.com/community/NautilusScriptsHowto)
# NAUTILUS_SCRIPT_CURRENT_URI='file://... current directory'
# NAUTILUS_SCRIPT_SELECTED_FILE_PATHS='... each file is terminated with \n'
# NAUTILUS_SCRIPT_SELECTED_URIS='file://... each file is terminated with \n'
# NAUTILUS_SCRIPT_WINDOW_GEOMETRY=1920x999+0+0
echo -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed -z 's/.$//' | xsel -b -i
zenity --info --no-wrap --no-markup
--title="File name(s) copied to Clipboard:"
--text="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
You can save the above script as ~/.local/share/nautilus/scripts/CopyFile_Path
and make it executable¹. After that, you can select some files in Nautilus, right click and go to the Scripts → CopyFile_Path menu item.
You can also group your scripts under sub-directories of the scripts/
directory. They will be displayed as sub-menu items in the right-click menu.
For more details, please look at another of my answers here.
¹ Refer to the man
pages of xsel and zenity commands. If you don't have these commands on your system, you will have to sudo apt install xsel zenity
.
~/.local/share/nautilus/scripts
. – FedKad Jan 31 '23 at 08:33