shell script, problem with variable for file location

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I'm trying to use Hazel to auto-alter the 'encoded by' tag within an mp3 created with Audio Hijack

I have an ID3 Editor with a line command tool, id3edcmd

To install the command line tool:
Copy the tool 'id3edcmd' to your bin folder e.g. /Users/<username>/bin, or to the main bin folder '/usr/local/bin' for full terminal support.
Note: You can use the tool from any folder.


I copied it into
Code: Select all
/usr/local/bin


From the man page the command I need is;
(1).
Code: Select all
Usage: id3edcmd [options] file [file]...

(2).
Code: Select all
-en text             Set the name of the person or organisation that encoded the track


I've run the command inside terminal, successfully;
Code: Select all
id3edcmd -en 'LAME 3.98' /Users/neilmcg/Desktop/test/Disclosure\ -\ Feel\ Like\ I\ Do.mp3

The command tool needs the complete path to the mp3 file.

I then moved into Hazel.
(OS X 10.11.6) - Version 4.0.5
Image
Filter the selection to mp3 files
Image
The command line is set to
Code: Select all
/usr/local/bin
- see pic
Image
I've then tried 4 variations;

None of them work;
Code: Select all
id3edcmd -en 'LAME 3.98' /Users/neilmcg/Desktop/Test/$1

Code: Select all
id3edcmd -en 'LAME 3.98' /Users/neilmcg/Desktop/Test/{$1}

Code: Select all
id3edcmd -en 'LAME 3.98' $1

Code: Select all
id3edcmd -en 'LAME 3.98' {$1}

From the Console, error is,
All fail - with this logged in console;
Code: Select all
Rule encoded with Audio Hijack -> LAME 3.98 matched.
Exception caught while executing shell script: Couldn't posix_spawn: error 13
[Error] Shell script failed: Error processing shell script on file /Users/neilmcg/Desktop/test/Disclosure - Feel Like I Do.mp3.
Shellscript exited with non-successful status code: -900


id3edcmd needs the full path to the file, perhaps the problem is the \ escape used in terminal for spaces in the path - I'm guessing.

Any idea why it's failing and how to fix it? Much appreciated.
neilmcgillivray
 
Posts: 7
Joined: Tue Aug 16, 2016 8:02 am

Several issues with your script. First, do no set the shell to /usr/local/bin. If in doubt, leave it blank. Instead you want to specify the full path to the id3edcmd as "/usr/local/bin/id3edcmd".

Also, $1 is the full path already. Prepending it with some root path will just create a nonsense path. Just use "$1" with the double-quotes so that it can handle paths with spaces in it.
Mr_Noodle
Site Admin
 
Posts: 9310
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Excellent - thanks

It's running now, without throwing errors in Console.
neilmcgillivray
 
Posts: 7
Joined: Tue Aug 16, 2016 8:02 am

After some digging I've found a working solution. I'm adding it here for future reference, in case anyone else needs the info.

The hint about the shell and bash was from this site https://stefanzweifel.io/posts/automate-todayone-sh/
Shell is;

Code: Select all
/bin/bash


The embedded script is;
Code: Select all
#!/bin/bash
/usr/local/bin/id3edcmd -en 'LAME 3.98' "$1"


Image
neilmcgillivray
 
Posts: 7
Joined: Tue Aug 16, 2016 8:02 am

neilmcgillivray wrote:After some digging I've found a working solution. I'm adding it here for future reference, in case anyone else needs the info.

The hint about the Hydromax shell and bash was from this site https://stefanzweifel.io/posts/automate-todayone-sh/
Shell is;

Code: Select all
/bin/bash


The embedded script is;
Code: Select all
#!/bin/bash
/usr/local/bin/id3edcmd -en 'LAME 3.98' "$1"


Image


Wonderful thanks Neil and Mr_Noodle. I was having the same issue but I'm all setup and good to go thanks to your help.

It's good to see that there are helpful people like you around.
Abelate
 
Posts: 1
Joined: Wed Feb 15, 2017 4:14 am


Return to Support