在涉及社交个人资料时,使用AppleScript清理地址簿表现得非常奇怪

时间:2012-03-20 10:26:59

标签: applescript addressbook duplicate-removal

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

通过所有社交网络和同步软件/服务,联系人将填充社交网络URL,最近Apple将社交个人资料添加到其地址簿脚本词典

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

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

    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
  

错误“Erreur dans地址簿:Le gestionnaire AppleEventaéchoué。”数字-10000

任何线索?可根据要求提供源代码

- P

1 个答案:

答案 0 :(得分:1)

我认为这可能有用......问题在于社交个人资料与电子邮件,电话号码等联系信息无关......也许它会在操作系统更新后运行,也许它已经在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