Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have been using a script that does not work anymore in mountain lion even though I have changed the words "address book" to "contacts".

If you select all the contacts, and then use the script, it will find all those contacts that are not in a group for you. The short script is available at MacOSX hints:

http://hints.macworld.com/article.php?story=20051126084705352

Can anybody modify this to work again? Thanks in advance.

share|improve this question

1 Answer 1

Try this, I have a huge contact list so testing it fully on mine would take a billion years. But the initial tests work

These sort of script are really only handy on small lists as the overhead with all the repeating is exponential the larger they get.

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
share|improve this answer
1  
Thank you. I just discovered a much easier way to do this in Mountain Lion. Just use a smart group. Card is not a member of any group. This produces a list of those cards that are not in any group. –  emaven Sep 29 '12 at 8:31
1  
I suppose I could have suggested that, but you asked for the script to be fixed or modified. Which I did. Answering your question. It would be good if you accept it as answering the question. Would make me feel I did not waste my time on a badly asked question. Cheers –  markhunte Sep 29 '12 at 12:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.