Intenta esto, tengo una enorme lista de contactos para probar plenamente en la mina tomaría millones de años. Pero las pruebas iniciales de trabajo
Este tipo de secuencia de comandos son realmente sólo es práctico en listas pequeñas como la sobrecarga con todas las de repetición es exponencial, el más grande de ellos.
property orphan : "Orphans"
tell application "Contacts"
if not (exists group orphan) then
(*Create the new group*)
make new group at the end of groups with properties {name:orphan}
end if
--set thePeople to first person whose first name is "TEST"
(*get all entries*)
set thePeople to every person
(*iterate through the entries*)
repeat with i from 1 to number of items in thePeople
(*get the entry*)
set this_person to item i of thePeople
(*get the entries group list *)
set inGroup to name of group of this_person
if inGroup is {} then
(* entry is not in any group*)
add this_person to group orphan
save
else if inGroup contains "Orphans" and inGroup is not equal to {"Orphans"} then
(*if entry is already in a group/s then check it is not also in¬
Orphans or only in orphans*)
(* entry is in orphans and another group so remove it from orphans*)
remove this_person from group orphan
save
end if
end repeat
save
end tell