Page 1 of 1

Shell script statement works in Terminal, fails in Hazel

PostPosted: Sun Apr 17, 2016 5:47 am
by WorkflowsGuy
I have written a shell script that

1) reads the comment tag from an MP3 file with ExifTool
2) converts the MP3 to a different format with ffmpeg
3) writes back the comment to the new mp3 with eyeD3 with the line

Code: Select all
/usr/local/bin/eyed3 --encoding utf8 --v2 --comment "$sMP3TagComment" "$sOriginalDateiname"

This works perfectly when running it in Terminal or in CodeRunner.

However, when using it as an external script in a Hazel rule and applying it to the same MP3 file, the "eyeD3" command line fails with the error
Code: Select all
eyeD3: error: argument -c/--comment: invalid UnicodeArg value: 'eyeD3: error: argument -c/--comment: invalid UnicodeArg value: '1. Unerm\xc3\xbcdlich, engagiert und streitbar - Bischof Erwin Kr\xc3\xa4utler im Gespr\xc3\xa4ch.'

I am puzzled why running the script through Hazel would seem to influence string encoding?

Re: Shell script statement works in Terminal, fails in Hazel

PostPosted: Mon Apr 18, 2016 10:05 am
by Mr_Noodle
I'm not sure but keep in mind that when run in Hazel, your environment is different. Maybe eyeD3 requires some env var to be set.

Re: Shell script statement works in Terminal, fails in Hazel

PostPosted: Mon Apr 18, 2016 12:28 pm
by WorkflowsGuy
Thank you for pointing this out.

I had assumed that the default character encoding for every shell environment is UTF-8, but obviously not.

After adding

Code: Select all
LC_CTYPE=UTF-8
export LC_CTYPE

as the first statements of my script, it now also works correctly in Hazel.