How can I call Don Melton's transcode_video script from a shell script? I'm trying to create a Folder Action to transcode videos using Don Melton's scripts.

When I run the script, transcode_video complains that HandBrakeCLI is not available, but when I run the command directly from the terminal it runs fine.



I'm guessing this is some kind of bash script security thing, but I'm an amateur at this game. Is there a way round this? I've had to revert to calling HandBrakeCLI directly, which is not as easy to optimise.
Two things:


Fix your path. This is as simple as adding the following as your first line. I installed the scripts through gem, not git, so transcode_video is in /usr/local/bin - you'll need to set it as appropriate.


export PATH="/usr/local/bin:$PATH"


Make sure you cd into the directory you want to save the files into, as a step too. Otherwise, writes them out into $HOME, which appears to be the default working directory for automator bash scripts.


My total working code:

export PATH="/usr/local/bin:$PATH"
for f in "$@"
do
    echo $f &gt; /tmp/filename.txt
    cd ~/Desktop/SAmple/
    transcode-video --mp4 -v "$f" &gt; /tmp/transcode.out
done