(Self-answered) Run bash script with % (percent) symbol in arguments (error "The system cannot find the file specified")
Posted: 30 Oct 2026 12:00
Problem
I tried to run a bash script to convert my image and rescale it, passing a scale with % (percent) symbol, but it failed. I put the script on a custom button (Toolbar > Customize Toolbar…) but that could also be done with a custom contextual menu (Tools > Configuration… (F9) > General > Custom Event Actions).
My script looks like this (note: I entered button action without final semicolon ; but it's automatically added in the end):
However it will fail with:
I tried to escape the % with double percent %%, but to no avail.
Solution
EDIT 2026-11-01, XYplorer XYplorer 27.00.0100: the old solution wasn't working, this is the correct one:
Surround hyphenated options with single or double quotes:
---
OLD solution (didn't work when tried again on 2026-11-01, XYplorer 27.00.0100):
Following other scripts I found online, I surrounded the bash command with single quotes:
and it worked.
I tried to run a bash script to convert my image and rescale it, passing a scale with % (percent) symbol, but it failed. I put the script on a custom button (Toolbar > Customize Toolbar…) but that could also be done with a custom contextual menu (Tools > Configuration… (F9) > General > Custom Event Actions).
My script looks like this (note: I entered button action without final semicolon ; but it's automatically added in the end):
Code: Select all
run bash "path\to\scripts\convert_image.sh" jpg webp -s 50%AttemptsThe system cannot find the file specified.
I tried to escape the % with double percent %%, but to no avail.
Solution
EDIT 2026-11-01, XYplorer XYplorer 27.00.0100: the old solution wasn't working, this is the correct one:
Surround hyphenated options with single or double quotes:
Code: Select all
run bash "path\to\scripts\convert_image.sh" jpg webp "-s" 50%OLD solution (didn't work when tried again on 2026-11-01, XYplorer 27.00.0100):
Following other scripts I found online, I surrounded the bash command with single quotes:
Code: Select all
run bash '"path\to\scripts\convert_image.sh" jpg webp -s 50%'