如何在Contacts.app(Address Book.app)中列出人员的电子邮件地址

时间:2014-03-04 23:03:57

标签: macos bash applescript

我在bash中寻找一种方法来传输

中文件的内容
~/Library/Application Support/AddressBook/AddressBook-v22.abcddb

以文字格式。我相信它是一个SQL文件,但我不太确定,因为我之前从未见过.abcddb扩展。这甚至可以在shell中使用吗?

1 个答案:

答案 0 :(得分:1)

osascript -e 'set text item delimiters to linefeed' -e 'tell application "Contacts" to (value of email 1 of people) as text'

要获取电子邮件地址,名字和姓氏的列表,请在AppleScript编辑器中运行如下脚本:

set out to ""
tell application "Contacts" to repeat with p in people
    if emails of p is {} then
        set e to ""
    else
        set e to value of email 1 of p
    end if
    set out to out & e & ";" & first name of p & ";" & last name of p & linefeed
end repeat
out