Cool. I'll take a look at you new macro.
Since you are so industrious today, and you came up with a very compact solution earlier, I'd love to have your thoughts on search for a string in the email address.
For example, I want to find all Contacts that use a specific domain in their email address.
I need a list of Contact Full Name, with associated emails that match.
I've done a lot of searching on the 'net, and have not found anything useful.
Here is the script I have so far. I know I can continue it and brute-force a solution, but surely there must be a better method.
Here is what I have so far:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
use BPLIB : script "BridgePlus" version "1.3.2"
--- SEARCH EMAIL ADDRESS FOR STRING ---
set emailFilter to "gmail"
--- I WANT RESULTS LIKE THIS ---
-- {"Full Name", {"email address1", "email address2"}
set desiredResult to {¬
{"John Doe", {"jdoe_home@gmail.com", "jdoe_work@gmail.com"}}, ¬
{"Jack Smith", "jsmith@gmail.com"}}
tell application "Contacts"
--- RETURNS EMPTY ITEM FOR PERSONS, THAT DO NOT HAVE MATCHING EMAIL ---
set emailList to value of every email of every person whose (value contains emailFilter)
### FAILS: DOES NOT WORK ###
# set peoList to name of every person whose email's value contains emailFilter
### SO I HAVE TO USE THIS ###
# which returns ALL Contacts
# when I just want those with matching emails
set peoList to name of every person
end tell
--- THIS WORKS NICELY, BUT ... ---
-- how to I associate Contact Name with each email?
set emailClean to BPLIB's listByDeletingBlanksIn:emailList