如果选中公司框,则将联系人分类到智能组中

Sort Contacts into Smart Group if Company Box is Checked

我在 apple's support site 找到了一个 Applescript,用于将任何带有 "Company" 复选标记的联系人分类到 "Business" 组中:

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

失败于:

            make new person at end of group groupName with data singlePerson

有错误:

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

有没有人知道一种方法来整理所有勾选为 "Company" 的联系人?

例如,我不想要任何有公司名称但是个人卡的人:

但我确实希望勾选 Company 框的公司:

注意:我被定向到 SO 以获取我在 this question.

中发布的 Ask Different 的程序化答案

使用duplicate命令将一个人复制到一个组中(不适用于智能组)

property groupName : "Business"
tell application "Contacts"
    if (name of groups) does not contain groupName then
        make new group at end of groups with properties {name:groupName}
    end if
    with timeout of 600 seconds
        set tIDs to id of people of group groupName
        repeat with singlePerson in (get people whose its company is true)
            if tIDs does not contain id of singlePerson then
                duplicate singlePerson to group groupName
            end if
        end repeat
        save
    end timeout
end tell