Page 1 of 1
Run hazel rules using applescript

Posted:
Sun Jun 24, 2012 4:51 am
by flynn
Hello,
I wanted to make an applescript that would run force hazel rules to run so that I could integrate that in an automator workflow and run rules consecutively when they should have had a certain amount of time pass between the first time it's run and the second time.
Hazel doesn't come with an applescript dictionary. Any Ideas? thanks
Re: Run hazel rules using applescript

Posted:
Sun Jun 24, 2012 12:42 pm
by a_freyer
Hazel isn't intended to be triggered manually.
If you really must do what you're asking, I'd suggest creating a very specifically named file if you want to trigger rules. I'd create this file in the parent folder of the folder you actually want to modify and do something like this:
- Code: Select all
If (all) ...
Name is "THIS HIGHLY SPECIFIC EXACT MATCH FILE NAME"
And subfolder depth is 0
Then
Run rules on folder contents.
Move file to the trash
Then have your other rules only active for subfolder depths greater than 0.
However, as I'm sure you can see this is a very hacked-up solution. Perhaps if you spell out exactly what you're looking to do, we can avoid this.
Re: Run hazel rules using applescript

Posted:
Sun Jun 24, 2012 6:05 pm
by flynn
I have a rule in my downloads folder which extracts contents of a dmg file to the downloads folder. (My downloads folder automatically opens .pkg and .dmg, moves .app to app folder, unzips zip files etc), and the problem is that when it extracts from the dmg into the downloads folder, rules aren't ran directly after and the newly added files are left there sitting for a while unless I run the rules manually.
Re: Run hazel rules using applescript

Posted:
Mon Jun 25, 2012 3:34 pm
by Mr_Noodle
You may want to consult the logs to see why that's the case. Are the files being added to the Downloads folder directly or to some subfolder?
Re: Run hazel rules using applescript

Posted:
Mon Jun 25, 2012 11:33 pm
by flynn
Directly to the downloads folder. They are eventually processed, but there is some time that passes between when they are added and when they are process that is bigger than usual. It usually turns around a minute or so, whereas they are normally processed in a few seconds.
Re: Run hazel rules using applescript

Posted:
Thu Jun 28, 2012 3:20 pm
by Mr_Noodle
Do the logs indicate anything? Maybe the files are busy?
Re: Run hazel rules using applescript

Posted:
Thu Jun 28, 2012 11:51 pm
by flynn
I turned off all the rules other then the ones concerning the downloads folder. There is nothing going on with the files just after being moved to the downloads folder. Hazel just processes them after a while of doing nothing.
One thing I noticed though before turning the rules off was that since the logs are constantly being updated and I have a rule that deletes big log files to prevent hazel logs from taking up too much space like they did a one time, is that hazel basically says processing folder Logs continuously. I know this is kinda off topic but can I prevent hazel from checking a folder too often ?
Re: Run hazel rules using applescript

Posted:
Fri Jun 29, 2012 2:57 pm
by Mr_Noodle
It's a bad idea to monitor Hazel's log folder. You are creating a loop. Basically, Hazel processes log folder, generating log messages which causes write to files in the log folder which generate file events which makes Hazel keep processing the folder. Hazel does rotate logs on its own on a weekly basis so I suggest you let it do its job in that case.
It may be the case that this is causing severe resource utilization causing all sorts of other delays on your machine.