Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Split first and last names in Address Book via AppleScript Apps
Lots of mobile phones do not support the possibility of entering a first and a last name for a contact. When first syncing the phone with the Mac, all names like "John Doe" are contained in the last name field, and have an empty first name. The following AppleScript splits the names correctly:
tell application "Address Book"
  repeat with this_person in every person
    set first_name to first name of this_person as string
    set last_name to last name of this_person as string
    if first_name = "missing value" then
      set myname to words of last_name
      set newFirstName to 1st word of last_name
      set newLastName to ""
      try
        set newLastName to 2nd word of last_name
      end try
      set first name of this_person to newFirstName
      set last name of this_person to newLastName
    end if
  end repeat
end tell
[robg adds: I haven't tested this one. If you're going to try it, please back up your Address Book database first. You can do this within the program from the File menu, or in the Finder by duplicating your user's Library » Application Support » Address Book folder.]
    •    
  • Currently 3.20 / 5
  You rated: 2 / 5 (5 votes cast)
 
[7,195 views]  

Split first and last names in Address Book via AppleScript | 4 comments | Create New Account
Click here to return to the 'Split first and last names in Address Book via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Split first and last names in Address Book via AppleScript
Authored by: peterholdn on Aug 16, '07 11:47:29AM

No comment on the script as written - but you might want to add just a little more complexity to deal with people whose names are not just two words. I think of my friend Mary Ann, and I know some people with multiple words to their last name - I know a Van der Boer, for example.

I also know a few people who only go by one name. Not sure what the script would do when there is no second word in the last name field to react to.

Maybe add a chunk that request user input in the case of any name that has other than two words.

---
Relax, it's only ones and zeroes.



[ Reply to This | # ]
isync and Pantech C150
Authored by: numbtucci on Aug 18, '07 08:49:22AM

Does anyone know how to add the AT &T Pantech c150 so that it is recognized by isync? I know there is a way to edit the metaclass.plist but not sure of the code that has to be entered.



[ Reply to This | # ]
G4 DIGITAL AUDIO VIDEO NOISE
Authored by: flexaret on Aug 18, '07 10:01:15PM

I bought a used Power Mac G4 Digital Audio for using Final Cut Pro. It was impossible to use, as importing video through Firewire gave loads of white and colored thin streaks in the image. I tried every solution, even buying another computer, but still wanted to repair this one. Nobody could come up with a cure, from Apple to all kinds of really High Tech Mac Techs. I even tried replacing the logic board and no cure. I finally replaced the CPU (processor) and the streaks are gone. Just a weird Mac problem and an oddball fix after much experimenting. My wish is to get this out on the inetrnet and around everywhere so that others having this same problem can cure it.



[ Reply to This | # ]
Split first and last names in Address Book via AppleScript
Authored by: aelath on Nov 02, '11 12:30:39PM

Just wanted to respond about this little script. I fiddled with it a little bit to get it to work for me. It was really just two edits to make my life easier.
1) I changed "2nd word" under the try to "last word", because I had entries with multiple words but no last names with multiple words.
2) In order to work correctly you need to save the changes. I put a "save" in the script near the end, right before "end tell".
That did the trick for me! I didn't have 2000 contacts to change, only 200, so I guess that makes me lazy.



[ Reply to This | # ]