Page 1 of 1

Hazel doesnt launch my appelscript

PostPosted: Fri Jun 24, 2011 8:19 pm
by Chuggett
Hi Guys

I followed a post in the Recepie Exchange for automatically converting MKVs/AVIs etc to m4v files with an applescript that I have asked Hazel to launch. It was all working perfectly, flowing from folder to folder, then one day, Hazel would not complete a rule that called an applescript.

The rule said that if any file was an mkv or avi file, coloured Blue, and was not modified in the last 5 mins, then launch an external script.

Code: Select all
on hazelProcessFile(theFile)
   tell application "Finder"
      try
         --Set to red label to indicate processing
         set label index of theFile to 2
         
         --Assemble original and new file paths
         set origFilepath to quoted form of POSIX path of (theFile as alias)
         set newFilepath to (characters 1 thru -5 of origFilepath as string) & "m4v'"
         
         --Start the conversion
         set shellCommand to "nice /Applications/HandBrakeCLI -i " & origFilepath & " -o " & newFilepath & " --preset=\"Normal\" ;"
         do shell script shellCommand
         
         --Set the label to orange
         set label index of theFile to 3
      end try
   end tell
   tell application "Finder"
      set movieName to name of item theFile
   end tell
   tell application "GrowlHelperApp"
      set the allNotificationsList to {"Handbrake convert complete"}
      set the enabledNotificationsList to {"Handbrake convert complete"}
      register as application "Handbrake Encode Growler" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "HandBrake"
      notify with name "Handbrake convert complete" title "Handbrake conversion complete" description "The video \"" & movieName & "\" has been converted." application name "Handbrake Encode Growler"
   end tell
   
end hazelProcessFile


My Growl notification would pop up and tell me that the file had been complete. But it hadnt.

So i tried to simplify the rule and said if any file is labelled Blue, run this script. I forced the rule to run, and the same result..it bypassed Handbrake CLI.

I use the same script on another machine, and it works fine.

I have since repaired permissions, changed an read/write settings in the file info to read/write all users but still nothing.

In the end, i guess its not really a Hazel issue, as Hazel is working beautifully on my machine with other rules and i really cant wait for version 3 to come out, but has anybody come accross this kind of thing and offer any suggestions to fix it.

Thanks in advance.

Re: Hazel doesnt launch my appelscript

PostPosted: Sun Jun 26, 2011 11:21 pm
by Chuggett
Further to my above post, i have created just a shellscript to run and that seems to work fine:

Code: Select all
nice /Applications/HandbrakeCLI -i "$1" -o "newFilepath" --preset="Normal"


My only problem is that i dont yet know how to control this so that the new file takes the file name of the original and adds an m4v extension. Im going to keep searching till i find it or work out why my applescript is just bypassing the handbrake command.

Re: Hazel doesnt launch my appelscript

PostPosted: Mon Jun 27, 2011 3:05 am
by Chuggett
I have managed to correct the broken process with a shell script that i found here on Hazels forums. Im happy again...but i am curious as to why the applescript was being bypassed. If anyone knows, please let me know.

Thanks
Chris

Re: Hazel doesnt launch my appelscript

PostPosted: Mon Jun 27, 2011 2:51 pm
by Mr_Noodle
If actions were executed after the script, then the script was executed successfully. I'd check the logs to see if the script output any messages.