Nautilus Scripts

Introduction
It's very easy to extend the capabilities of Files, the Gnome file manager, using scripts.

Just create a script and save it in your home directory $HOME/.local/share/nautilus/scripts/, for it to appear in the context menu Scripts.

This page of the manual of Nautilus explains the necessary details.

The environment variables passed to the script are as follows:

Terminal
Create a simple script that allows us to open a terminal in the current directory by setting its size and position: echo'#!/usr/bin/env bash gnome-terminal --geometry=100x24-0-0 ' > $HOME/.local/share/nautilus/scripts/Terminal chmod a+x $HOME/.local/share/nautilus/scripts/Terminal

Search
Create a simple script that allows us to open the file search window in the current directory: echo'#!/usr/bin/env bash CURRENT_URI=$(echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed -e 's+^file://++g' -e 's+%20+ +g') gnome-search-tool --hidden --path="$CURRENT_URI" ' > $HOME/.local/share/nautilus/scripts/Search chmod a+x $HOME/.local/share/nautilus/scripts/URL_Decode
 * 1) cwd

GPRename
Create a simple script that allows us to open the program GPRename in the current directory: echo'#!/usr/bin/env bash CURRENT_URI=$(echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed -e 's+^file://++g' -e 's+%20+ +g') gprename "$CURRENT_URI" ' > $HOME/.local/share/nautilus/scripts/GPRename chmod a+x $HOME/.local/share/nautilus/scripts/GPRename
 * 1) cwd

Decompress
Create a script that allows us to unzip the selected files with the extension .ace, .rar and .zip into the current directory: echo'#!/usr/bin/env bash IFS=$'\012' CURRENT_URI=$(echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed -e 's+^file://++g' -e 's+%20+ +g') for FILE in $(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sort -u | grep "..") do    CURRENT_EXT=$(echo "$FILE" | tr '[:upper:]' '[:lower:]' | sed 's+^.*\.++g') if [ "$CURRENT_EXT" = "ace" ]; then unace e -c- -o -y "$FILE" "$CURRENT_URI" elif [ "$CURRENT_EXT" = "rar" ]; then unrar e -kb -o+ -y "$FILE" "$CURRENT_URI" elif [ "$CURRENT_EXT" = "zip" ]; then unzip -d "$CURRENT_URI" -o -j "$FILE" fi done ' > $HOME/.local/share/nautilus/scripts/Decompress chmod a+x $HOME/.local/share/nautilus/scripts/Decompress
 * 1) redirect stdout and stderr for debugging
 * 2) exec 1>/tmp/Decompress.out
 * 3) exec 2>/tmp/Decompress.err
 * 1) split only using newline
 * 1) cwd

URL_Decode
Create a script that allows us to decode the name of an encoded URL file (e.g. from "%20" to " "): echo'#!/usr/bin/env bash IFS=$'\012' for FILE in $(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sort -u | grep "..") do    IS_ENCODED=$(echo "$FILE" | grep '%..') if [ -n "$IS_ENCODED" ]; then NEWFILE=$(echo "$FILE" | php -R 'echo urldecode($argn);') mv -f "$FILE" "$NEWFILE" fi done ' > $HOME/.local/share/nautilus/scripts/URL_Decode chmod a+x $HOME/.local/share/nautilus/scripts/URL_Decode
 * 1) split only using newline

This script needs the following package to work properly:

sudo apt install php-cli

PDF_2_Images
Creiamo uno script che ci permetta di estrarre nella directory corrente tutte le immagini presenti in un file PDF: echo'#!/usr/bin/env bash IFS=$'\012' CURRENT_URI=$(echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed -e 's+^file://++g' -e 's+%20+ +g') for FILE in $(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sort -u | grep "..") do    cd "$CURRENT_URI" NO_EXT=$(echo "$FILE" | tr '[:space:]' '_' | sed -e 's+^.*/++g' -e 's+\..*++g') pdfimages -all "$FILE" "$NO_EXT" done ' > $HOME/.local/share/nautilus/scripts/PDF_2_Images chmod a+x $HOME/.local/share/nautilus/scripts/PDF_2_Images
 * 1) split only using newline
 * 1) cwd

pyRenamer
Create a simple script that allows us to open the program pyRenamer in the current directory: echo'#!/usr/bin/env bash CURRENT_URI=$(echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed -e 's+^file://++g' -e 's+%20+ +g') pyrenamer --root / "$CURRENT_URI" ' > $HOME/.local/share/nautilus/scripts/pyRenamer chmod a+x $HOME/.local/share/nautilus/scripts/pyRenamer
 * 1) cwd