1

I found an Applescript at apple's support site to sort any contact with the "Company" checkmark checked into a "Business" group:

property groupName : "Business"
tell application "Contacts"
    if (name of groups as list) does not contain groupName then
        make new group at end of groups with properties {name:groupName}
    end if
    repeat with singlePerson in people
        if company of singlePerson is true then
            if (people of group groupName as list) does not contain (singlePerson as list) then
                make new person at end of group groupName with data singlePerson
            end if
        end if
    end repeat
    save
end tell

It fails on:

            make new person at end of group groupName with data singlePerson

With error:

error "Contacts got an error: AppleEvent handler failed." number -10000

Does anyone know of a method to sort out all contacts checkmarked as "Company"?

For example I do NOT want anyone who has a company name but is an individual card:

enter image description here

But I DO want companies with the Company box checkmarked:

enter image description here

1 Answer 1

2

Update:

I originally thought You don't need Applescript to do this.

And you could create a Smart Group that does it for you.

enter image description here


enter image description here


BUT the 'Company: is set' is not for the checkbox. Its for the actual Company text field.

So you cannot use the above for this as it does not care if the checkbox for company is ticked or not. It only cares if there is text in the Company field.

So Applescript IS the way to go. And using company is true which refers to the checkbox.

    property groupName : "Business"
tell application "Contacts"

    if not (exists (group groupName)) then
        make new group with properties {name:groupName}
    end if
    set the_people to people whose company is true
    repeat with i from 1 to number of items in the_people
        set this_person to item i of the_people
        add this_person to group groupName
        save
    end repeat
end tell
3
  • This does not work. I am looking for a method that only selects contacts with the "Company" box checkmarked. This method selects everyone who has a company name filled in (including individual contacts) Jan 27, 2015 at 14:02
  • See my edit above in my Q. Jan 27, 2015 at 14:05
  • @Chrismas007 , Ah I see what you are after now. See updated answer
    – markhunte
    Jan 27, 2015 at 18:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .