I would like to use a Nautilus script that calls a Python script of mine, passing as a required argument the path of the current folder. This would avoid me the trouble of refactoring the Python script to extract the folder path from the URI provided by $NAUTILUS_SCRIPT_CURRENT_URI
. Ideally, I would like to have something like this.
#!/bin/bash
$current_folder=EXTRACT THE FOLDER PATH FROM NAUTILUS_SCRIPT_CURRENT_URI
python3 /path/to/my/file.py $current_folder -optarg 1
Where $current_folder
is a required argument for my Python script, and -optarg 1
indicates that my script also accepts optional arguments.
How do I extract the current folder with bash script?
The bash command
pwd
can do this for you! Use that in your script like so