Help with parsing a text string in address book and moving it to 'related person' field

I am wanting to make a little applescript that will go thru my contacts and find data in the NOTES field and parse it slightly and move it to another field.  (sorry if parsing isn't the right word here)
The data to be found is a GPS coordinate with this EXACT format:
<Lat:12.345678><Lon:-12.345678>
...the only thing different from this example is the digits, and the number of digits.
What I want to end up doing is deleting this data from the NOTES field, but leaving any other data, (this part sounds difficult to do to, to me!)
And moving it to a related person field with the label gps, and the coordinate now reading exactly:
12.345678,-12.345678
(FYI, you can copy/paste a coordinate like this very fast into the maps app on iPhone and locate it instantly)
Thanks for the help on this
If this is too complicated I can break up the process into steps.  I know how to do some of it, but not sure about the parsing, and then delete just part of the notes field...
Thanks!

Hi,
This script work here, try it :
tell application "Address Book"
    repeat with thisContact in (get people)
        set tNote to note of thisContact
        if tNote is not missing value and "<Lat:" is in tNote and "<Lon:" is in tNote then
            set {GPS_value, newNote} to my getGPS_coordinate(tNote)
            if newNote is not "" then -- no error
                set gpsField to (related names of thisContact whose its label = "gps")
                if gpsField is not {} then
                    set value of (item 1 of gpsField) to GPS_value
                else -- field "gps" is empty
                    make new related name at end of related names of thisContact with properties {label:"gps", value:GPS_value}
                end if
                set note of thisContact to newNote
            end if
        end if
    end repeat
    save
end tell
on getGPS_coordinate(this_note)
    set oldTid to text item delimiters
    set {tLat, tLon, newNote} to {"", "", ""}
    try
        set text item delimiters to "<Lat:"
        set tLat to text item 2 of this_note
        set text item delimiters to "<Lon:"
        set tLon to text item 2 of this_note
        set text item delimiters to ">"
        set {tLat, tLon} to {text item 1 of tLat, text item 1 of tLon} -- get values (lat... and long...)
        set text item delimiters to "<Lat:" & tLat & "><Lon:" & tLon & ">"
        set this_note to text items of this_note
        set text item delimiters to " "
        set newNote to this_note as string -- delete GPS coordinate in this note
    end try
    set text item delimiters to oldTid
    return {tLat & "," & tLon, newNote}
end getGPS_coordinate

Similar Messages

  • Sync address book and calendar 8830 with 8130 via DM

    I just changed from using an 8130 and now use an 8830.  I assumed I could use DM to backup my 8130 and then restore it to my 8830.  However, when I do this, many items do migrate, but not 2 of the most important ... my address book and calendar.  Both are personal devices and are not linked with any work email server, so that's not the issue.  I do notice that in the backup file from my 8130 the address book is called "Address Book - All" and similar with the calendar.  However, with the 8830, it is labeled as only "Address Book".  I'm wondering if this is the problem?  I'm hoping someone can help me get my address book and calendar migrated to my new device.
    Thanks!
    BTW, I already tried wiping the new 8830 ... that did nothing.

    In Desktop Manager, use the application Switch Device Wizard.
    Message Edited by JSanders on 06-29-2009 05:52 PM
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • I force quitted my address book and everything in it disappeared. Help!

    It was not backed up and I had hundreds of customer email addresses in there. A major loss. I would be very grateful for any help.
    There is nothing in the address book and nothing comes up when I type in names in the the 'To' column.

    Hello, and also welcome to the Discussions.
    To supplement Austin's excellent response, in the Finder, open Home/Library/Application Support and look for a folder named AddressBook -- do you find it? Within are other folders and files, including AddressBook.data, AddressBook.data.beforesave and AddressBook.data.previous.
    One of the latter two, should contain what you need, if the first one in incomplete, or newly created. Delete AddressBook.data, and rename a copy of one of the latter two, to be simply the same name.
    In the application AB, the same could result from File/Revert to Addressbook Backup, but save a copy of the AddressBook folder before trying.
    Ernie

  • Sync to Entourage and Not Mac Address book and ical HELP

    I just got a brand new MacBook Pro (no more PC)!!!! My I Sync my phone and it put all the data in ical and address book. I use Entourage and thats where i would like all my info to go. how do i set up itunes to go to entourage and not the apple sofware.
    And Can i sync via bluetooth?
    thanks you
    Brad "new Mac guy" Glaberson
    Message was edited by: bradley Glaberson

    The isync database, as I called it, is really just the master database from which ical, address book, bookmarks, etc., are stored, and it's used for syncing with the .mac service. Entourage can sync with it too, just go to the Entourage menu, choose Preferences, and look under General Preferences for Sync Services. Then check the boxes you want -- I just wanted the contacts to be the same in Entourage and Address Book so I only checked that one. The calendar is kind of funky because iCal uses separate calendars to group events, and I think if you check that box, iCal will then get a new calendar called Entourage, or something like that, in which all the Entourage events will go to and from. That is, I think Entourage will sync only with that iCal calendar, but I could be wrong about that since I don't use it.
    Once you check the contacts box, Entourage will populate with all the contacts in your Address Book, and I think if you don't already have contacts there (that is if you've only been using Entourage for your contacts) then it will ask you if you want to put all your Entourage contacts into Address Book. I just don't remember.
    Surely someone else out there is more familiar with this, but it should get you started.

  • Synchronising Entourage to Mac Address Book and iCal

    I've done my initial sync between Entourage 2008 (Version 12.3.5), iCal and Mac Address Books but now if I update anything in the Entourage Calendar or Address Book, it fails to then send the info to iCal and Mac Address Book. Therefore, the info isn't making it to my iPhone which is updated to the Phone iOS 6.0.1.
    Has anyone had the same problems and if so how did you fix it?
    I've done a lot of reading to try and find out what is wrong but I'm just getting more and more frustrated. I did read something about having the Daylight Saving Modes switched on or off but can't remember if it was on or off.
    I don't see why I should have to export/import ALL the info every single time. It used to work quite ok but just ins't anymore?? I think it somehow worked through iSync?
    Oh, and on top of that, if I put anything on my iPhone Address Book or Calendar, it's not synchronising to my Mac! Actually, I've just checked and addresses are synchronising to my Address Book but not then Synchronising to the Entourage Address Book.
    And I seem to be getting double ups of entries on my iPhone from my Calendar if I make a change, instead of updating the info in the actual event already created AND I get balnk "new events"! Rather annoying!!
    I don't use iCloud either. Apparently that would just make things even worse.
    HELP!!
    PS. It seems the only way to sync things is by remembering what I've added to either Address Boook or Calendars on either one of the devices/programs and update it manually on all the others via exporting a single vcf file ...

    The isync database, as I called it, is really just the master database from which ical, address book, bookmarks, etc., are stored, and it's used for syncing with the .mac service. Entourage can sync with it too, just go to the Entourage menu, choose Preferences, and look under General Preferences for Sync Services. Then check the boxes you want -- I just wanted the contacts to be the same in Entourage and Address Book so I only checked that one. The calendar is kind of funky because iCal uses separate calendars to group events, and I think if you check that box, iCal will then get a new calendar called Entourage, or something like that, in which all the Entourage events will go to and from. That is, I think Entourage will sync only with that iCal calendar, but I could be wrong about that since I don't use it.
    Once you check the contacts box, Entourage will populate with all the contacts in your Address Book, and I think if you don't already have contacts there (that is if you've only been using Entourage for your contacts) then it will ask you if you want to put all your Entourage contacts into Address Book. I just don't remember.
    Surely someone else out there is more familiar with this, but it should get you started.

  • Address book and communigate problem

    Hi,
    I need some advice about how I can transport my contacts list (currently in the form of a csv, comma separated value text file) into address book and then export in a format that can be used by the communigate pro interface. I am using macdock to host my site and have just paid for their mailbox add-on, but want to import these addresses into the address book within the communigate account.
    I have managed to import the list into address book but it saves all the emails under one contact card, plus misses out a large number of them.
    Has anyone been through a similar procedure?
    Any help most appreciated!
    Ben

    Thank you. Update my system? Do you mean the OS or the Mail program? My bosses name is Rose. When I type in Rose, Mail doesn't link to the Address Book. Neither the last name or the email address appears.

  • Dail from Address Book and Use Mac as a speakerphone??

    I really, really, really want to be able to dail a phone number from Address Book and then talk to the person on the phone line using my G5... I tried a couple of softwares but was.....OH SO DISAPPIONTED.......Does anyone know what I can do to remedy this.
    It would also be okay if I could have a little app that does that an be able to redail the number until I get an answer... .......Please Help... I spend a lot of time on my phone and also need to multitask....

    If you can't get the exported .csv file to work you might consider using Migration Assistant: http://support.apple.com/kb/HT2518, particular if you need to move more than just your contacts.  There is some granularity in the options on what to transfer but I'm not sure if you can choose to just your migrate contacts.

  • Hello i need a help about script to export translatable text strings from ai files and import them back

    Hello i need a help about script to export translatable text strings from ai files and import them back after editing, thanks in advance

    Lanny -
    Thank you for taking the time to help with this problem. Can I just say however that as someone who has posted a first comment here and quite clearly never used a forum like this before, your comment unfortunately comes across as very excluding. It makes me feel there are a set of unwritten rules that I should know, and that I don't know them shows that the forum is not for me. In short, it's exactly the kind of response that stops people like me using forums like this.
    I'm sure it's not intended to be received like this and I am sure that the way you have responded is quite normal in the rules of a forum like this. However, it is not normal for those of us who aren't familiar with forums and who only encounter them when they have a genuine problem. This is why I hope it is helpful to respond in full.
    The reason I posted here is as follows. I was directed here by the apple support website. The original comment seemed to be the only one I could find which referred to my issue. As there is no obvious guidance on how to post on a forum like this it seemed perfectly reasonable to try and join in a conversation which might solve more than one problem at once.
    Bee's reply however is both helpful and warm. This could in fact be a template for how new members should be welcomed and inducted into the rules of the forum in a friendly and inclusive way. Thank you very much indeed Bee!

  • Need help with Mail address book and calendar.

    Hello,
    I am a new Mac User. I just purchased my first MacBook. My goal is to switch totally over to Mac for both home and work. I was able to get the mail program to pull down my exchange mail, however it does not appear to have taken in my address book.
    My goal would be for my machine to totally sync up with my mail, and calendar the same way that my iPhone does. Is there a way to do this?
    If I can't get my contacts and calendar to "sync". I will not be able to use my Mac at work.
    Any help or assistance would be greatly appreciated.
    Regards,
    Jason

    I do not believe you can sync your data between Outlook and Address Book and iCal. You can transfer data using a third-party utility, Outlook2Mac. However, you could integrate with your Outlook account using Entourage, one of the Office 2008 applications. You would have to purchase Microsoft Office 2008.

  • I use macbook and lion os. I want to sync gmail contact with address book. For this i goto preference in address book and select "sync with google". I put my gmail details. However, the sync does not happen. Please help.

    i use macbook and lion os 10.7.2.
    I want to sync gmail contact with address book.
    For this i goto preference in address book and select "sync with google".
    I put my gmail details.
    However, the sync does not happen.
    Please help.

    You should have signed in with that address in the first place, but there is a workaround: go to System preferences>Mail, Contacts@ Calendars and add your @me.com address as an account there.

  • Importing text file to address book?

    I created a text tab-delimited file for import. From within Address Book, ran "Import". Matched up field names. All looked good. When I clicked on "OK" basically very little happened. After a few seconds the blue OK button became clear but nothing else. I advanced another record, clicked OK on it and same few seconds then nothing. I expected all the records to be imported.
    In any case, tried this individually with a few records, then checked the Address Book and none of the info was in there.
    Is this some kind of bug? I don't see that I did anything that was wrong with the import.
    Advice appreciated.
    Richard

    Not sure if this helps, but ...
    I made a quick text file to see if I could duplicate your problem. I put in three lines, the first with field names (First, Last, Work) and the other two with corresponding data. The values within each line were tab separated. When I ran AB's import I had to match up the third field to correspond with email (work). I flicked through the displayed records (all two of them!!) and they displayed as contact cards. I then clicked OK, and unlike your description, the import dialogue immediately vanished. The records were correctly imported.
    When you look at the records in the import dialog do they all display correctly?
    Could it be a 10.4.3 issue?
    After attempting to do the import, has your contact count gone up?
    What happens if you select the "last import" group?

  • Please Help! Suddenly unable to open Mail, Address Book etc

    This morning when I woke up my IBook my Mail was still open from yesterday. When I tried to open ICal it kept crashing. So I restarted and then suddenly ITunes, Mail, Address Book and ICal would not open at all!! (However, it seems that iPhoto, Appleworks, Safari etc is fine).
    I do have a IPhone, but haven't synced in a week or so. Not sure that that would be relevant at all.
    The other weird thing that has happened, is that all the info on the top right hand corner of my menu bar (my airport, date, weather snitch, spotlight etc) disappeared a few weeks ago. It has been blank there ever since. When I just did a check of those applications ( internet connect, weather snitch) they also didn't open now.
    Thanks in advance for any advice at all...
    BTW, I just ran verify disk, and it stopped with this error message:
    " the underlying task reported failure on exit" - The volume needs to be repaired.
    Really hoping that someone can help me with this!
    Message was edited by: ALSVLA

    Hi ALSVLA, and a warm welcome to the forums!
    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Tiger Install disc that came with your computer, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu. (In Mac OS X 10.4 or later, you must select your language first.)
    *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
    3. Click the First Aid tab.
    4. Click the disclosure triangle to the left of the hard drive icon to display the names of your hard disk volumes and partitions.
    5. Select your Mac OS X volume.
    6. Click Repair. Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    The usual reason why updates fail or mess things up, is if Permissions are not fixed before & after every update, with a reboot... you may get a partial update when the installer finds it doesn't have Permissions to change one obscure little part of the OS, leaving you with a mix of OS versions.
    Some people get away without Repairing Permissions for years, some for only days.
    If Permissions are wrong before applying an update, you could get mixed OS versions, if Directory is the slightest messed up, who knows!

  • Problems synching iPhone 3Gs with Address Book and Calender

    I have an iPhone 3Gs and have begun to notice that information is not being synched between Calender and the phone and Address Book and the phone. I now also have duplicate contacts for all contacts that were in my orginal iPhone before I upgraded. I suspect it has something to do with mobileme (which I don't subscribe to) and I have tried all the various synch options in iTunes. I know people have been having the problem and have solved theirs with the help of mobileme. How can I solve it without subscribing?

    Yes I have a similar problem.
    I lost all my contacts (today 23rd Mat 2011) on my 3G iPhone and the Address Book on my Mac Pro also.
    The contacts in my MS Outlook were intact  I run Outlook:Mac 2011.
    They have only just fixed the issue with the Calendar in this version 2 weeks ago an MS issue.
    I plugged in the iPhone last night to charge and synch and this morming the phone had no contacts and I had lost all the address Book I had some  group headings  (greyed out)
    It's almost like a plot to get Outlook users frustrated and make them switch but, Outlook is too good.
    Outlook:mac 2011 contacts does not synch with Mac address book

  • Had to wipe my drive so I could do a clean install of snow leopard Now I look every where on how to move bookmarks, address book and I cal settings.  I have them back up on a external drive with Time machine but can not move, copy or restore my old sett d

    Had to wipe my drive so I could do a clean install of snow leopard.   Now I have look every where on how to move bookmarks, address book and I cal settings.  I have them back up on a external drive with Time machine but can not move, copy or restore my old settings.  The instructions I have found or no help or needs more clarafication on what to do.

    Use migration assistant to move your files.  http://support.apple.com/kb/HT4889

  • Issues with Global Address Book and Out of Office saying Exchange is Offline.

    So we have an Exchange 2010 server that has been running fine for quite a few years. We recently changed our firewall to an ASA 5510 and created all the firewall rules necessary to have email work through it. Everything works fine so naturally we thought
    everything was good to go.
    Then I started getting messages that the Out of Office wasn't working an that when users where trying to set their away message they would get a message from outlook that the exchange server was unavailable, yet when I
    check the outlook client it would say Connected to Microsoft Exchange at the bottom. I thought this was crazy so I started looking further into it and it turns out that the name for the server owa.xxxxxx.net points to a public address, which of course lives
    on the outside interface to the ASA. In ASA world it doesn't like private space (ie. 192.168.x.x) talking to the outside interface and drops the packets, where our old firewall did not. So as a short term fix I had the users using OWA site with a internal
    address to set their out of office message. This worked fine until today when I rebooted the email server and started getting support calls saying that when users where selecting the To: button in a new email that once again they were getting messages saying
    that they were not connected to exchange, yet they once again outlook said they were. I then started playing with the host name owa.xxxxxx.net again. This time I changed the hosts file on a box and pointed the internal IP of the exchange server to that
    host name. Restarted the outlook client and things started to work as they should. I have played with split DNS to see if this would help so I wouldn't have to do this with every client in the network, and it was promising until I realized that we many hosts
    that use this domain and an external DNS server that takes care of these requests that now the internal users will never reach. Funny part is that if we take one of our laptops out side the network everything works fine as well.
    So I'm guessing that some of the processes that connect Outlook to Exchange use the FQDN of the server or IP address, and that other things such as the Global Address Book and Out of Office use the External Host Name.
    Any help to point these request at the Internal FQDN/IP would be great, or if someone can think of another way of dealing with this issue would be greatly appreciated.

    Hi Titan,
    correct me if i have missed something but are users able to look up contacts in GAL?
    If you update (ex mobile number for a user) then run the following commands(one for each line):
       Get-GlobalAddressList | update-GlobalAddressList
       Get-AddressList | update-AddressList
    Get-OfflineAddressBook | Update-OfflineAddressBook
    Restart Your Outlook  in 5 min,then do a manual OAB download.Is info on that user updated?
    Does GAL from frm OWA?
    if im not wrong,Status and Out of Office use EWS for status update.
    Please run the following command:
    Get-WebServicesVirtualDirectory -Identity “mailserver01\EWS (Default Web Site)” |fl *internalUrl*
    where mailserver01 is the server that is having the issue.
    Then please check if internal URL is correct for that server (and those that are having issues.
    Please mark as helpful if you find my contribution useful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you. Thank you! Off2work

Maybe you are looking for