i am trying to add a custom action to the nemo file manager. The purpose of the action is just to replace all whitespace in the filename by _.My action file looks like this:[Nemo Action]Name=NormalizeComment=replace all occurences of   by _Exec=<normalize.sh %F>Selection=AnyExtensions=AnyThe bash script normalize.sh is i the actions directory and looks like this:#!/usr/bin/bashif [[ $# != 1 ]]    then exit 1finame=`echo $1 | sed s/\ /\_/g`mv $1 $nameexit 0Does anybody know, why this isn't working?
custom nemo actions / bash script
bash;cinnamon;file manager;nemo
The problem:Your problem is so trivial, that %F is the filename, and the filename contains spaces, so you're calling the script by this way:normalize.sh my fancy fileSo $1 becomes my, $2 becomes fancy and $3 becomes file. Now $# becomes 3.Fix 1 (recommended):To fix that. you don't need to check the number of arguments. Then you can use $@ instead of $1. The script will look like this:#!/usr/bin/bashname=`echo $@ | sed s/\ /\_/g`mv $@ $nameexit 0Fix 2:Another solution is to put quotes around %F. The correct code would be this:[Nemo Action]Name=NormalizeComment=replace all occurences of   by _Exec=<normalize.sh %F>Selection=AnyExtensions=AnyImproved script:#!/usr/bin/env bashmv $@ $(tr ' ' '_' <<< '$@')exit 0Normally bash is on /bin/bash. As yours seems to be on /usr/bin/bash (the first time that I see this) I put a universal workaround to run bash wherever it be. However you can see the path to bash typing which bash on a terminal.Removed conditional to count arguments.Why use sed for that existing tr?Instead of echo the file to sed or tr, better use <<<.Why not to put all in one line?