Unrar and Handbrake questions

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Unrar and Handbrake questions Sun Jun 22, 2014 1:04 pm • by scottfwalter
So this is what I want to accomplish:

1. If a directory has a rar file in it then unrar it with command line version of The Unarchiver
2. Once the file has been unrared I want to use Handbrake CLI to convert it to mv4.

So I have setup two rules: one to unrar and one to convert. I have a couple questions:

1. In my HandbrakeCLI rule I have this script:

NAME=$(basename "$1")
NAME=${NAME%.*}
/Users/scott/bin/HandBrakeCLI -i "$1" -o "/Users/scott/Desktop/$NAME.m4v" --preset='Apple TV3'

However I seem to have to hard code the path to my home directory. If I do something like ~/Desktop in the output directory the command doesn't run. Is there a way to specify my home directory in the script (I'm using an embedded script). Can I use shell variables such as $HOME?

2. Is there a way to tell Hazel to not process a file until another rule has finished? In other words how does Hazel know that my unrar command is done? I don't want it to try to handbrake the rar file if the unrar process hasn't finished.

Thanks in advance, Scott
scottfwalter
 
Posts: 47
Joined: Thu Jan 03, 2013 11:10 am

Re: Unrar and Handbrake questions Mon Jun 23, 2014 3:36 pm • by Mr_Noodle
Is there a reason why this isn't under a single rule? Also, is there a reason why you are using the Unarchiver instead of the built-in Unarchive action?

Not sure about $HOME. Most environment variables needs to be set explicitly since scripts in Hazel are run in a different environment (i.e. no shell). I suggest adding in a "echo $HOME" line, turning on debugging and see if it is printed out in the logs.
Mr_Noodle
Site Admin
 
Posts: 11226
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Unrar and Handbrake questions Mon Jun 23, 2014 4:31 pm • by scottfwalter
Mr_Noodle wrote:Is there a reason why this isn't under a single rule? Also, is there a reason why you are using the Unarchiver instead of the built-in Unarchive action?

Not sure about $HOME. Most environment variables needs to be set explicitly since scripts in Hazel are run in a different environment (i.e. no shell). I suggest adding in a "echo $HOME" line, turning on debugging and see if it is printed out in the logs.


I guess when I was working on the individual steps I didn't think to put them under one rule. There's no reason why I need two rules. Also I didn't realize unarchive would work with rar files. That is good to know!
scottfwalter
 
Posts: 47
Joined: Thu Jan 03, 2013 11:10 am


Return to Open Discussion