See: Execute a Shell Script, Quoting Strings.
It describes how the arguments to a command (find
) in this case is not a big long string, but an array of strings, with each one being an individual argument.
If you use "$KMVAR_Var"
then that single argument will be the contents of the Var
variable. If the Var
variable contains quotes or *
s or spaces, those are just characters in the argument.
If you use $KMVAR_Var
, then the contents of the Var
variable will be split by spaces, and each part will be an argument. Any quotes or *
s it may contains are still just characters in the arguments. So if Var
contained β"abc def ghi"
β that would but three arguments, "abc
, def
, and ghi"
.
It is extremely difficult to build up a legitimate full command in a variable and expect it to work, so almost always what you want to do is have the full command in the Execute Shell Script action.
When writing the command on the command line, if you say ls *.txt
, it is actually the shell that processes that, the *.txt
is not passed to the ls
command, instead the ls
command receives an array of arguments, each one being a file name that matches the *.txt
pattern.
This is why when you write it in the find
command, you need the "*.mp4"
, because you don't want the shell to expand that to a list of all the matching files in the directory. So you have to quote it to stop that happening.
Now, lucky for you your extnesions will never have spaces, and you donβt want the *
expanded, so if you have a variable that contains -name *.mp4 -o -name *.mov -o -name *.mxf
, and you pass it as just $KMVAR_Var
(without any quotes) you get exactly what you want - the components separated by spaces all sent as arguments with no further processing.
However your path definitely might have spaces in it, so it does not have that luxury. But now you can build up the -name
string, and then your command is:
find "$KMVAR_debug_Package" -type f \( $KMVAR_local_Video_Find \)
and that should work fine.
Note that if you include the (
)
in the KMVAR_local_Video_Find variable, then they would not have the \
for the same reason - it is there to stop it from meaning something to the shell, which would not be required if it was within the variable.