I'm trying to create a simple macro that runs a script using ffmpeg to convert mp3 to wav
I found out how to do it in Terminal, but when I use the same script in KM, it says:
2023-06-05 09:24:09 Action 13889867 failed: Execute a Shell Script failed with script error: text-script: line 1: ffmpeg: command not found
2023-06-05 09:24:09 Execute a Shell Script failed with script error: text-script: line 1: ffmpeg: command not found. Macro “Convert selected MP3 files to Wav” cancelled (while executing Execute Shell Script).
I'm in no way familiar with shell scripting and all I do is copy what I see online and use it, so maybe there's something I need to add to the script to make it work with KM.
There's this other topic, but I have no idea what is being said, so I can't take any info from it:
If you're going to expand your use of shell scripts in KM you need to become familiar with "Execute a Shell Script" page of the Wiki, particularly the section on paths.
In a nutshell, by default a KM shell script environment only knows about utilities installed into /usr/bin, /bin, /usr/sbin, /sbin. You can add more entries to that list, but often the simplest solution is to use the full path to the utility in your script. So if ffmpeg is installed in /opt/homebrew/bin your script would be
/opt/homebrew/bin/ffmpeg -i "$KMVAR_Local__Path".mp3 and so on...
Note that you don't need the "replace space with \space action" -- the double-quotes handle spaces in the shell path for you. Again, see the appropriate section of the Wiki page.
My issue now is with the scripting itself, not just how it works inside KM.
It's not something I know yet. I'm learning as I build macros.
I found it here: /opt/anaconda3/bin/ffmpeg and it's now working! I also had something wrong with my script where I was removing the "mp3" from the path, but not the dot so it was looking for files with 2 dots at the end like ..mp3