${f// /_}
means: replace all occurences of spaces with underscores
${1%/*}
means: remove shortest match of /*
from end of string
${1##*/}
means: remove longest match of */
from front of string
when it says
mv "$1"
what is meant by $1
$1
is the first positional parameter. So if your script has this
echo $1
and you call like this
foo.sh 111
then output will be
111
finally the find command is being closed with
-exec <something> _ {} \;
now what is the use of an underscore_
, curly braces{}
and a backslash followed by a colon above\;
?
The underscore is a placeholder for parameter $0
The {} \;
idiom is used with find
, to say: run this command once for each file
[ -f "$file" ] || continue
means: if $file
is not a FILE, then continue (immediately end the current iteration of the loop and start the next)