Addres book formatting

Discussion in 'Mac Programming' started by Timpion, Dec 29, 2010.

  1. Timpion macrumors newbie

    Mar 17, 2009

    I just got a new phone, but I got some problems getting all my contacts from the old one. I was able to get them into addressbook, but the formatting is not optimal.

    I made a script that merges the doubles (eg "Leonardo Di caprio" and "Leonardo Di caprio1")

    The only problem now is all the names are in the last name field (eg:
    FirstName: "", LastName: "Leonardo Di caprio")

    Can someone help me with a script that would split the lastname at the first space " " and put the first part in the firstname field
    (eg:FirstName: "Leonardo", LastName: "Di caprio")

    I cant find how to do it

    I got this far... (I am not really pro at applescript yet :p)

    tell application "Address Book"
    	set peopleToChange to people whose (name) contains " "
    	repeat with thePerson in peopleToChange
    		set theName to the name of thePerson
    	end repeat
    end tell
    Thanks a lot!!

  2. andy 111r macrumors newbie

    andy 111r

    Nov 13, 2010
    Are you not just getting confused by address book preferences.

    ie you have the option of showing first name before or after last name with a radio button in general prefs.
  3. Matthew Yohe macrumors 68020

    Oct 12, 2006
    I would recommend just exporting as CSV or similar: ( ) and bring it into Excel or Google Spreadsheets.

    Then you can easily split off last names using a textual formula that looks for a space or something and puts it in the correct cell.

    Import that list into address book.
  4. Timpion thread starter macrumors newbie

    Mar 17, 2009
    Importing in a spreadsheet app is a very good (the best) idea. I ll do that next time! :cool:

    I already did it with some scripts which worked quit well, but when I was done and used the "merge" function, addressbook threw away all data from people with two conflicting numbers.

    Leonardo di caprio
    home xxx xx xx
    ---merge with---
    Leonardo di caprio
    home yyy yy yy
    Leonardo di caprio
    home xxx xx xx

    I had that a lot because while importing all my numbers where set to "home"(thanks to the great way data is stored on sim cards :rolleyes:)

    And ofcourse I noticed it the day after I deleted the backups I made (stupid not to keep the backups)

    anyway, If anyone wants to take a look at the scripts, pm me. I am not posting them since they are loose bits of code (eg: one script to delete spaces, one to merge names,....)

Share This Page