AppleScript: Activate all mail rules with "sort: " in their name 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



How do I get the names of all mail rules?
How do I filter these names for containing the string "sort: "?
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.