I would like a script to list all regular Groups in my Contacts application, but NOT the Smart Groups.
The following does return all the Groups, including the Smart Groups.
set text item delimiters to return
tell application "Contacts" to (get the name of every group) as string
I there a way for AppleScript to know whether a group is smart or not ? I did not find anything in the dictionary so I am afraid that the answer is “no”, but I thought I’d ask here anyway.
If you get the id of the group, the end of the ID contains test such as “ABGroup” or “ABSmartGroup”
You can parse the text for this part
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
property groupList : {}
property typeList : {}
set tid to text item delimiters
set text item delimiters to ":"
tell application "Contacts"
set typeList to {name, id} of groups
repeat with i from 1 to count item 1 of typeList
set gid to item i of item 2 of typeList
set gname to item i of item 1 of typeList
set end of groupList to {gname, last text item of gid}
end repeat
end tell
set text item delimiters to tid
get groupList