Reversing the first and last name of contacts on OSX Yosemite

Reading time: about 2 minutes

So I recently got a smartphone. It has all sorts of touch screens and stuff. The nice folks at the store were kind enough to import all my contacts from my most recent dumbphone onto the fancy smartphone. Handy, I thought.

Then I realized:

All the imported contacts had first and last names swapped. So I poked around and found the "Display Order" setting for the "Contacts" application and set it to "Last, First". Easy, I thought.

Then I realized:

Backwards is still backwards, even if you display it forwards. This messed with basically everything. Upon adding a new contact, I'd add it properly, and find that my newly added contact now displayed backwards...because the whole system was displaying backwards to show the backwards names in a way that made them seem forwards.

Backward backward = forward. Backward backward backward = backward.

I thought to myself: "self, you're a programmer, surely you can write a script to accomplish such a task."

That was yesterday at about 16:45. Now it is today at 23:11. About an hour ago, this finally happened:

tell application "Contacts"
        set selectedPeople to the selection
        repeat with currentPerson in selectedPeople
                set oldLastName to the last name of currentPerson
                set oldFirstName to the first name of currentPerson
                set the first name of currentPerson to oldLastName
                set the last name of currentPerson to oldFirstName
        end repeat
        save
end tell

Install the script as a system service for Contacts.app, select the backwards names, and hit the button. Easy, I thought.

YMMV

Additionally, natural language programming is really just awful.

Relevant links that took me way too long to find:


Date: 2014-Dec-16
Tags: applescript contacts
Previous: on sleep
Next: The Chapstick Manəˈfestō
This entry was originally written and published on Squiggle.city and was imported in January 2018.
This is a neat squiggle.city project