Here is what I am using for reading a watermark on an audio file:
do shell script "/usr/local/bin/audiowmark get " & /path/to/file.wav
When an audio file has a watermark (which has been applied previously via a different command with audiowmark), I am able to process the result just fine. The problem comes when an audio file doesn’t have a watermark.
If I run the command directly in terminal, the command escapes without outputting anything…so, I tried:
if result is "" then display dialogue "No Watermark on this Audio File"
This didn’t yield any success.
However, when running as part of my larger automator action, I do get presented with an error in finder:
The actions "Run Applescript" encountered an error: "audiowmark: error parsing commandline args (use audiowmark -h)"
So I also tried:
if result is "audiowmark: error parsing commandline args (use audiowmark -h)" then
display dialog "No Watermark on this Audio File"
That also wasn’t successful, and I am still presented with the same Finder error.
Exists several ways to handle shell command errors. In your case, I would use try block. Following will return watermark on the success, or missing value in other case.
set theWatermark to (do shell script "/usr/local/bin/audiowmark get " & "/path/to/file.wav")
on error errorMessage
display dialog errorMessage
return missing value
I don’t have the utility installed for testing, but it would seem the OP could set set a variable to the output of audiomark. If there is no output, then an error will occur and it can be assumed that a watermark was not found. This appears to be exactly what KniazidisR’s suggestion does.