1

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?

0
1

The bash command pwd can do this for you! Use that in your script like so

#!/bin/bash
python3  /path/to/my/file.py $(pwd) -optarg 1
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.