0

I would like an AppleScript to activate all rules that have the string "sort: " in their names.

As far as I know this is how to enable a mail rule:

tell application "Mail" to set enabled of rule "sort: foo bar" to true
  1. How do I get the names of all mail rules?
  2. How do I filter these names for containing the string "sort: "?
1

Pretty simple one-liner:
tell application "Mail" to set enabled of rules whose name starts with "sort: " to true

You don’t even need to get all those rules or their names; however if you want to do so it’s just as straightforward:
tell application "Mail" to get name of rules whose name starts with "sort: "

Note: your example starts with sort: but you asked about strings containing that string. If that is what you want then swap contains for starts with in the code I provided.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .