0

I have bash script below to AI upscale a bunch of images and then re encode them to reduce file size, it works fine if I call the script from the terminal but not when I select it in nautilus as a nautilus script.

I have put the script in the nautilus scripts folder and it appears in the menu, the script runs but the part that re encodes the images does not work and I don't know why because there is no debugging output for scripts called from nautilus.

Maybe there are some environment variables that do not work if launched from nautilus, thats all I can think of.

#!/bin/sh
PS4='$LINENO: '
OIFS="$IFS"
IFS=$'\n'
set -x
for arg
do
    mkdir "${arg}US"
    /Programs/realesrgan-ncnn-vulkan -i "$arg" -o "${arg}US" -n realesrgan-x4plus -s 4 -f jpg
    rm -rf "$arg"
    cd "${arg}US"
    DIR="${arg}US/*"
    for picture in $DIR
    do
    nice -19 /usr/bin/cjpeg -quality 85 "$picture" > "${picture%.*}RC.jpg"
    rm "$picture"
    done
done
IFS="$OIFS"
3
  • Put exec > ~/debuglog 2>&1 at the top and you'll get your logs Commented Mar 30, 2023 at 14:35
  • Thanks muru, I was able to debug and found that I just need to iterate over files after changing directory so changed to 'for picture in *.jpg' and it works in nautilus as well, it seems nautilus stops the script when their is an error in the loop but terminal does not. Commented Mar 31, 2023 at 14:39
  • You can post that as an answer, maybe it will help someone. Commented Apr 2, 2023 at 6:57

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.