Update ALL the bundles!
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 27 Mar 2012 11:38:35 -0400 |
parents |
1287b23ee8c3 |
children |
1d45e21ca4d7 |
#!/bin/bash
osascript -e "tell application \"Address Book\"" \
-e " set firstParam to \"$1\"" \
-e " set secondParam to \"$2\"" \
-e " set thirdParam to \"$3\"" \
-e " set fourthParam to \"$4\"" \
-e " set contactEmailLabel to \"\"" \
-e " set spaceOffset to (offset of \" \" in firstParam)" \
-e " if (spaceOffset is not equal to 0) then" \
-e " set AppleScript's text item delimiters to \" \"" \
-e " set firstName to (text item 1 of firstParam)" \
-e " set lastName to (text item 2 of firstParam)" \
-e " set firstEmailParam to secondParam" \
-e " set secondEmailParam to thirdParam" \
-e " else" \
-e " set firstName to firstParam" \
-e " set lastName to secondParam" \
-e " set firstEmailParam to thirdParam" \
-e " set secondEmailParam to fourthParam" \
-e " end if" \
-e " set atOffset to (offset of \"@\" in firstEmailParam)" \
-e " if (atOffset is not equal to 0) then" \
-e " set contactEmail to firstEmailParam" \
-e " else" \
-e " set contactEmailLabel to firstEmailParam" \
-e " set contactEmail to secondEmailParam" \
-e " end if" \
-e " if (contactEmailLabel is equal to \"\") then" \
-e " set contactEmailLabel to \"Home\"" \
-e " end if" \
-e " set newPerson to (make new person with properties {first name:firstName, last name:lastName})" \
-e " make new email at end of emails of newPerson with properties {label:contactEmailLabel, value:contactEmail}" \
-e " save" \
-e " if (newPerson exists) then" \
-e " if (firstName exists) then" \
-e " set returnString to (\"First name: \" & firstName)" \
-e " end if" \
-e " if (lastName exists) then" \
-e " set returnString to (returnString & \"; Last name: \" & lastName)" \
-e " end if" \
-e " if (contactEmailLabel exists) then" \
-e " set returnString to (returnString & \"; Email label: \" & contactEmailLabel)" \
-e " end if" \
-e " if (contactEmail exists) then" \
-e " set returnString to (returnString & \"; Email address: \" & contactEmail)" \
-e " end if" \
-e " return returnString" \
-e " end if" \
-e "end tell"