@
lex 我用完刪掉了……額,這是個很簡單的 AppleScript,大概思路是:
set 一個 record 型的 phoneticName,好像是 {phoneticLastname:"(*姓拼音*)", phoneticFirstname:"(*名拼音*)"}
剛開始的應該是用了 curl 這個命令把 Contacts 中選中名片的姓和名 post 到一個漢字轉拼音的網站(我忘了當時用的是哪個),把收到的結果「姓拼音」和「名拼音」分別存到 phoneticLastname 和 phoneticFirstname 裏面去,然後執行下面這個腳本(應該和以前那個大致相同)就行了……很快的。
tell application "Contacts"
if selection is not {} then
set the selectedProfiles to selection
set the profileNum to count items of selectedProfiles
repeat with i from 1 to profileNum
set the phonetic last name of item i of selectedProfiles to phoneticLastname of item i of phoneticName
set the phonetic first name of item i of selectedProfiles to phoneticFirstname of item i of phoneticName
end repeat
end if
save
end tell
如果要測試的話,不妨先給 phoneticName 賦個值試試,比如,你先在 Contacts 裏面選中 1 個名片,然後在 AppleScript Editor 裏面執行下面的腳本:
set phoneticName to {{phoneticLastname:"Xi", phoneticFirstname:"Jinping"},
tell application "Contacts"
if selection is not {} then
set the selectedProfiles to selection
set the profileNum to count items of selectedProfiles
repeat with i from 1 to profileNum
set the phonetic last name of item i of selectedProfiles to phoneticLastname of item i of phoneticName
set the phonetic first name of item i of selectedProfiles to phoneticFirstname of item i of phoneticName
end repeat
end if
save
end tell
應該就可以看到效果了……