Can anyone spot why this simple shell script is failing with KMVARs?

I have a macro that is triggered by a folder action. Really simple - when a file is added, it runs a shell script that starts an FFMpeg operation. This is what I want it to output:

ffmpeg -i '/Users/myusername/Movies/Compress Video - 1 Source/Boating in Lechlade.mp4' -filter:v fps=30 -preset fast -crf 28 '/Users/myusername/Movies/Compress Video - 2 Output/Boating in Lechlade.mp4'

I have two variables for the file names, the second one being an adaptation of the first one (to place it in a different location. This is the script:

ffmpeg -i '$KMVAR_FileName' -filter:v fps=30 -preset fast -crf 28 '$KMVAR_FileNameNew'

And the variables are populated with values.

When I run this macro, it seems like it has not changed those KMVARs into the correct text:

The error in the engine log is:

$KMVAR_FileName: No such file or directory. Macro “FFMpeg iMovie File” cancelled (while executing Execute Shell Script).

Can you see what I've missed here? I have other macros that use KMVAR in almost identical way, but they are not failing. I can't see what's wrong here, really.

Note: If I create that shell script in a Display Text window using those variables (But using %Variable%FileName% rather than $KMVAR_FileName), and then paste into Terminal, it works.

What have I missed here?

First thing that comes to the eye is that I think you may need double (rather than single) quotes to expand $varname references inside a command line string.

2 Likes

Arrgggh. Yes, that is it. I had no idea single/double made a difference. But now I do!

Not directly related to your question, and I'm not an expert at all. It seems you don't need this:
image

because you are not going to read the input text in the script. As long as the variables are set before running the script, you can use $KMVAR_VariableName to get the variable value.

Oh, right. I think I copied from one where this was required, and just followed suit (I hadn't thought to remove that part, but if it's not needed, I'll remove it). Thanks

Hey Lloyd,

See:

-Chris