Hazel and AppleScript

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

Moderators: Mr_Noodle, Moderators

Hazel and AppleScript Mon May 06, 2019 7:27 pm • by AAALLL
Hi, I see that you can use AppleScript in Hazel but I do not see a way to script Hazel.

I am assuming this is impossible but I want to make sure.

I would like to take in a CSV into AppleScript and use that to create folders. I know how to do all of that but I would also like to create Hazel rules to go along with this. For each one, I would like to pass a few rules into it, one being the name of the folder but also 2 or 3 others.

Is this possible?
AAALLL
 
Posts: 3
Joined: Mon May 06, 2019 7:14 pm

Re: Hazel and AppleScript Tue May 07, 2019 10:21 am • by Mr_Noodle
Can you go into more details about the folders? Are they under a common folder? Are the rules basically the same?
Mr_Noodle
Site Admin
 
Posts: 7945
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Hazel and AppleScript Tue May 07, 2019 12:51 pm • by AAALLL
Mr_Noodle wrote:Can you go into more details about the folders? Are they under a common folder? Are the rules basically the same?


Yes, it’s probably easiest if I give an example to go into more detail.

Folder 1 would be Mac, Folder 2 iPhone, Folder 3 Apple Watch, Folder 4 iPad. All of the following folders are contained in my Documents, Quarter 1 folder (which would be created by the AppleScript.

The rules would be if a Folder in my downloads folder has the name Mac in it or contains the word TouchBar, it would get be moved into the Mac folder.

Similar rules for the other folders like if the document is named iPhone, contains 5.8 or 6.5 then it would be moved into the iPhone folder.

So I would have a CSV that would look something like this (or mortified if necessary)
named Mac, contains TouchBar, etc
named iPhone, contains 5.8, contains 6.5, etc
named Apple Watch, contains 44, contains 40, etc
named iPad, contains 11, contains 12.9

The destination would be dead in from the AppleScript as it would be changing from Mac to iPhone etc.
AAALLL
 
Posts: 3
Joined: Mon May 06, 2019 7:14 pm

Re: Hazel and AppleScript Wed May 08, 2019 10:57 am • by Mr_Noodle
If you know AppleScript, you can instead have a script that reads in that file then returns a custom attribute to Hazel to tell it which folder to sort the file into. That way you can have a single rule instead of having to create new rules each time.
Mr_Noodle
Site Admin
 
Posts: 7945
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Hazel and AppleScript Thu May 09, 2019 2:39 pm • by AAALLL
Mr_Noodle wrote:If you know AppleScript, you can instead have a script that reads in that file then returns a custom attribute to Hazel to tell it which folder to sort the file into. That way you can have a single rule instead of having to create new rules each time.

Ok, is that what is documented here? https://www.noodlesoft.com/manual/hazel ... avascript/
AAALLL
 
Posts: 3
Joined: Mon May 06, 2019 7:14 pm

Re: Hazel and AppleScript Fri May 10, 2019 10:41 am • by Mr_Noodle
Yes, you want to use the hazelOutputAttributes to return values for custom attributes back to Hazel.
Mr_Noodle
Site Admin
 
Posts: 7945
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion