applescript - 当涉及到社交资料时,使用 AppleScript 清理地址簿的行为很奇怪

标签 applescript addressbook duplicates

我已成功编写和更新 AppleScript,以删除重复的电子邮件地址以及地址簿联系人中的重复 URL。

通过所有社交网络和同步软件/服务,联系人越来越多地被社交网络 URL 填充,最近 Apple 将社交配置文件添加到其地址簿脚本字典中

虽然我已成功处理重复的电子邮件、URL,甚至将社交网络 URL 与社交个人资料相匹配(并将其删除),但我在最后一步中被阻止:识别重复的社交个人资料并将其删除

虽然我可以成功识别重复的社交个人资料,但我还没有找到将其从联系人中删除的语法,就像使用重复的电子邮件地址可以轻松完成的操作一样

    repeat with email_id in duplicate_emails
        delete (emails of this_person whose id is email_id)
    end repeat

这是我执行时收到的错误消息

        delete (every social profile where id is socialProfile_id) in this_person

        delete (social profiles of this_person whose id is socialProfile_id)

        delete (every social profile whose id is socialProfile_id) in this_person

error "Erreur dans Address Book : Le gestionnaire AppleEvent a échoué." number -10000

有什么线索吗?可根据要求提供源代码

-- P

最佳答案

我认为这可能会起作用...问题是社交个人资料没有链接到电子邮件、电话号码等联系信息...也许它会在操作系统更新后起作用,也许它已经在 OSX 10.8 上起作用;- )

--© hubionmac.com 21.03.2012
-- example code that REMOVES ALL SOCIAL PROFILES
-- from every selected person in your Address Book
-- de-facebook, de-twitter,… you contacts ;-)

set mySelectedPersons to selection

repeat with aSelectedPerson in mySelectedPersons
  set social_ids to id of (every social profile of aSelectedPerson)
  repeat with social_id in social_ids
    my delete_social_profile(aSelectedPerson, social_id)
    save
  end repeat
end repeat

on delete_social_profile(thePerson, theID)
  --handler for removing social profiles from Address Book
  --only way since social profile is not contained by contact info or something else and so delete social profile xy does not work
  -- input a single reference to a person in the address book and
  -- a the uniq ID of a social profile as text
  tell application "Address Book"
    set social_index to 0
    repeat with i from 1 to (count of every social profile of thePerson)
      if (id of social profile i of thePerson) as text = theID as text then
        set social_index to i
        exit repeat
      end if
    end repeat
    if social_index = 0 then error "error on delete_social_profile, given ID was not found in this person"
    --you cannot delete/kill a social profile, but when you remove/take away
    --all stored information (username and URL) from it, it commits suicide
    --and is removed from the address book, philosophic programming, isn't it?
    set user name of social profile social_index of thePerson to ""
    set url of social profile social_index of thePerson to ""
  end tell
end delete_social_profile

关于applescript - 当涉及到社交资料时,使用 AppleScript 清理地址簿的行为很奇怪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9784980/

相关文章:

python - 如何从 Python 脚本中运行 AppleScript?

objective-c - Applescript 和 Cocoa 窗口位置

xcode - 通过 Applescript 将文件添加到 Xcode 项目目标

ios - 如何在 ABAdressbook 中链接 ABPerson

ios - 如何简单地检索 iOS7 中的联系人列表?

ios - 如何删除 CoreData 中的重复条目?

ruby - Applescript/Scripting Bridge 中的 QuickTimeX

swift - 从通讯录中获取 kABAddressCountryCodeKey

c# - Distinct() 方法是否保持序列的原始顺序不变?

python - 数据删除重复数据复杂