Simple Address Book AppleScript (substitution) question

I want an AppleScript to enter a single value in the 'Note' field for each record/contact in a certain group.
I wrote this:
tell application "Address Book"
repeat with allcontacts in group "Health"
set NewNote to "doctor"
set value of note to NewNote
end repeat
end tell
It compiles and seems to run OK. But nothing happens. What am I doing wrong?
(I wish I knew AS better Thanks!)
G5 DP 2 GHz   Mac OS X (10.4.10)   No Haxies; permissions frequently repaired etc

answer supplied in AS forum.

Similar Messages

  • Address book applescripting - slows computer via memory drain

    Hi,
    i've just got my new gleaming macbook pro - a return to mac after ~16 years. whew.
    I was a heavy user of categories and contacts in outlook - had two contact folders, A and B, with categories in each. Additionally for some categories there is a third field - location. In total there are 2500 contacts I deal with.
    To import my contacts was not trivial - i used little creatures O2M to bring over my messages, which worked well, but didn't give as great a result on contacts (lost a lot of fields). Then I used Abee on a csv file and found it was great - well worth the $10.
    I mapped my custom fields to related names custom fields.
    After a lot of reading i think that the best location for user defined fields (in my case group, category, and location) is as a custom named URL. This allows me to make Smart groups in address book to sort through these categories.
    So I wrote some applescript to move info from related names to URL fields. It steps through everyone in my address book and if the label "Group" exists in related names and the value is "B" then add a new URL and delete the related name label.
    The script is:
    tell application "Address Book"
    try
    repeat with this_person in every person
    set namestoremove to {}
    repeat with this_label in (get related name of this_person)
    if the label of this_label = "Group" and the value of this_label = "B" then
    make new url at end of urls of this_person with properties {label:"Group", value:"GroupB"}
    --properties of this_label
    set namestoremove to namestoremove & (id of this_label)
    --delete (related names of this_person whose id is id of this_label)
    end if
    end repeat
    repeat with name_id in namestoremove
    delete (related names of this_person whose id is name_id)
    end repeat
    save
    end repeat
    save
    end try
    end tell
    I have to acknowledge Trevor Harmon scripts for giving guidelines.
    I had to add the get statements to resolve properly the related names of the person
    The script works well on a small address book, but on the full book it slows to a crawl and stops.
    Of course I could re-import using abee - but that wont help me learn about address book scripts.
    Anyone see any problems that would cause the script to slow to a crawl? I assume its somehow consuming memory....

    Hello
    Accessing item in large list can be very slow in AppleScript unless appropriate coding method is used. Also the 'whose' filter can be very slow in filtering large collection of objects (though I doubt it is the case here).
    Anyway, you may try something like the script below which avoids the 'whose' filter.
    (NOT tested, for my environment is too for this.)
    --SCRIPT 1
    tell application "Address Book"
    repeat with p in (get every person)
    set p to p's contents -- # dereference the list item reference [1]
    tell p
    repeat with r in (get its related names)
    set r to r's contents -- # derefenence the list item reference [1]
    if r's label = "Group" and r's value = "B" then
    make new url at end of urls with properties {label:"Group", value:"GroupB"}
    delete r
    --delete related name id (get r's id) -- # alternative to the above [2]
    end if
    end repeat
    end tell
    --save addressbook
    end repeat
    save addressbook
    end tell
    [1] Dereferening the list item reference is costly operation in AppleScript.
    So dereferece it once (especially if it is used more than once in the iteration).
    [2] Use 'by ID' reference form if the 'delete r' does not work properly.
    (E.g., if r is in 'by index' reference form and there're multiple related names,
    'delete r' won't work properly due to changing index.)
    --END OF SCRIPT 1
    Or the following one which, in addition, implements a fast method to process large list.
    --SCRIPT 1a
    main()
    on main()
    script o
    property pp : {} -- # define large list as script object's property
    property rr : {} -- # idem
    tell application "Address Book"
    set pp to get every person
    repeat with p in my pp -- # use refenence to script object's property (i.e. my pp)
    set p to p's contents -- # dereference the list item reference [1]
    tell p
    set rr to get its related names
    repeat with r in my rr -- # use refenence to script object's property (i.e. my rr)
    set r to r's contents -- # dereference the list item reference [1]
    if r's label = "Group" and r's value = "B" then
    make new url at end of urls with properties {label:"Group", value:"GroupB"}
    delete r
    --delete related name id (get r's id) -- # alternative to the above [2]
    end if
    end repeat
    end tell
    --save addressbook
    end repeat
    save addressbook
    end tell
    end script
    tell o to run
    end main
    [1] Dereferening the list item reference is costly operation in AppleScript.
    So dereferece it once (especially if it is used more than once in the iteration).
    [2] Use 'by ID' reference form if the 'delete r' does not work properly.
    (E.g., if r is in 'by index' reference form and there're multiple related names,
    'delete r' won't work properly due to changing index.)
    --END OF SCRIPT 1a
    Hope this may help,
    H

  • Address Book Smart Group question

    Hello all,
    I want to create a Smart Group in Address Book that compiles people according to their job title.
    For example a group of everyone whose job title is 'Manager', i.e. Job Title contains Manager. But for some reason Job Title is not in the list of options when creating a Smart Group.
    Is there a way to make it work?
    Also, (a question for all the Snow Leopard users) is the option for Job Title there in OSX 10.6?
    I'm using Tiger 10.4.11.
    Thanks all.

    There is no such field for Job Title by default. If you select the Add Field item from the Card menu you can add that field to a card. However, I do not see Job Title as a search field for a Smart Group. I assume this is a bug which you can report here: Feedback.

  • Simple Address Book script help request

    I want an AppleScript to enter a single value in the 'Note' field for each record/contact in a certain group.
    I wrote this:
    tell application "Address Book"
    repeat with allcontacts in group "Health"
    set NewNote to "doctor"
    set value of note to NewNote
    end repeat
    end tell
    It compiles and seems to run OK. But nothing happens. What am I doing wrong?
    (I wish I knew AS better Thanks!)
    G5 DP 2 GHz   Mac OS X (10.4.10)   No Haxies; permissions frequently repaired etc

    Hi Mark you have the right idea, but you are slightly off..
    The biggest problem is in your loop. Like I said you do have the right idea though. When your looping with x in y "Y" must actually be a list of things, so in your case you need to build a list of all the contacts in group "Health" first.
    =================================================
    tell application "Address Book"
    set allContacts to every person in group "Health"
    repeat with singleContact in allContacts
    set singleContact's note to ((get singleContact's note) & return & "doctor" as string)
    end repeat
    end tell
    =================================================
    So as you can hopefully see first we build a list of the person entries contained in group "Health" then we step through that list.
    Also in my example we are preserving the contents of what may already exist in the note field rather then overwriting it.
    Hope that helps!

  • Address Book - Birthday Field question

    I was trying to make an entry on the birthday field in one of my contacts. The field does not give me an option to change the year of birth. It defaults to 2000.
    The other question is how can we set up alerts, so that we can maybe send out a card in advance? Thanks!
    Is there a way to fix this?
    imac user

    With the Address card in Edit mode you should be able to click the year field and after it highlights blue, change it to the year you need.
    According to Address book Help, in the Address Book Help Menu;
    You can keep track of contacts’ birthdays by creating a birthday calendar that automatically includes all the birthdays in your address book.
    1. In Address Book, make sure you’ve entered the birthdate for each contact whose birthday you want to track.
    2. In iCal, choose iCal > Preferences.
    3. In the General pane, select the “Show Birthdays calendar” checkbox.
    Birthdays in your address book are automatically added to the Birthdays calendar in iCal. When you add or remove birthday information in Address Book, the Birthdays calendar is also updated. You can’t make changes to the Birthdays calendar in iCal; to change it, you must edit the information in Address Book.
    You can check in iCal Help for info on setting alerts.

  • Faces to Address Book (Probably Stupid Question)

    Faces is coupled to address book in one way - it will suggest completions of names based on your Address Book entries. How about the other way? It seems there ought to be an easy way of choosing images from Faces as the custom image in Address Book - but I can't find it. Any suggestions?

    None that I'm aware of.
    You can add a single photo to a contact's info in the Address Book on your Mac, which will be transferred to your iPhone when syncing.

  • Address book and ical question

    Just upgraded to a new version MacBook Pro. Where can I find my address book and Ical on my old computer to bring it over?
    Thanks!

    See the following:
    Folders You Can Move to Your new Mac
    From the Home folder copy the contents of Documents, Movies, Music, Pictures, and Sites.
    In your /Home/Library/ folder:
    /Home/Library/Application Support/AddressBook (copy the whole folder)
    /Home/Library/Application Support/iCal (copy the whole folder)
    Also in /Home/Library/Application Support (copy whatever else you need including folders for any third-party applications)
    /Home/Library/Keychains (copy the whole folder)
    /Home/Library/Mail (copy the whole folder)
    /Home/Library/Preferences/ (copy the whole folder)
    /Home /Library/iTunes (copy the whole folder)
    /Home /Library/Safari (copy the whole folder)
    /Home /Library/Calendars (copy the whole folder)
    If you want cookies:
    /Home/Library/Cookies/Cookies.plist
    /Home/Library/Application Support/WebFoundation/HTTPCookies.plist
    For Entourage users:
    Entourage is in /Home/Documents/Microsoft User Data
    Also in /Home/Library/Preferences/Microsoft
    For FireFox:
    /Home/Library/Applications Support/FireFox
    /Home/Library/Preferences/org.mozilla.firefox.plist
    Credit goes Macjack for this information.

  • Address book field sort question

    Does anyone know how I can set upp my City field so I can sort by city? When I call customers for appointments I would like to sort by city so I can group all my calls together. Presently I group it in with Last name which does not work well if I want to do a mailing.
    Note to Palm; Why wouldn't Palm have set City field seperately so you can sort by city?
    Post relates to: Tungsten E2

    McAfee will warn you about anything sometimes lol. I've downloaded about 10 different programs and no viruses yet, so you shouldn't need worry. There should be some sort of advanced search tool on that site. You can also try using google. I do apologize the device does not come with that search method natively. I hope you find what you are looking for though through add ons.
    Let me know if you have any further questions and have a nice day.
    Post relates to: Treo 800w (Sprint)

  • Address Book Question -- IS THIS POSSIBLE ??

    Is "appending" information possible to address book ? Or like a way to add info from one address book to another with out it deleting anything on the one getting updated OR with out making duplicates of the contact info(s) ????
    Kinda like what we call a "incremintal back up". Like it is able to detect what is NEW info and ONLY save that to it while keeping all the old stuff on it.
    Let me explain --
    I got a tower and a laptop. Address Book (obviously) on both.
    Sometimes the one on my laptop gets some contact info added to it, while the one on my tower does not get that info added to it. OR vise versa.
    I want to combine the two and not lose anything and NOT have to do it manually. Because alot of info has gone down on both recently.
    But at the same time they both have alot of the SAME contacts on them because for a while I was trying to keep up with them and I was manually saving info, then putting it into the other. But recently things have gotten too far and I can not remember which has what, when..
    I NEED to do a incremental save/back up to one of them FROM the other one (combine the both with out causeing duplicates, or with out loseing anything).....
    Please help.
    Thanks -

    Cool, I guess thats good enough... It will get the job done the way I want, so THANKS ALOT Mike !!
    Problem solved.
    I wish in the future though Apple makes it possible to do it how I was saying. Hook your laptop up via firewire to your tower, then Basically a one button click to "append only new info" from the laptops address book. No questions about what to do with duplicates, etc.... just update ALL NEW info. Don't touch old.
    Thanks again though my friend, your reply was extremely valuable to me.

  • ICloud Deleted  Local Contacts From Address Book

    Okay, so I tried setting up an iCloud account so a family member could receive texts and messages via iChat. That was the original goal. I successfully set up an account, but iChat does not allow me to login via the iCloud account that I had set up. After sever attempts I decided to put that on the back burner until I had a little more time to look into it. In doing so I seem to have caused some other collateral damage which I didn't anticipate (see below).
    Unfortunately, as I logged out of iCloud on the iMac, it wiped/deleted every last contact that was in the address book. My question is: How can I get them back?
    I suspect that there is a "previous" or "prior" image of the data what was there. I'm guessing that Apple put some type of safeguard in place for just such an occurrance, though I could be wrong.
    The Machine is a 2011 27" iMac running 10.7.5. The last backup of the address book that I can get to is from 2011. Actually it's the Address Book Folder in users>Library>Applications Support.   I made a copy of the entire system drive AFTER everything was migrated over from the old system that was replaced, and have it on an external drive.
    Some notes:
    - Time Machine was not active or on
    - iCloud was never activated until just recently
    - the person does not own an iDevice with any of the contacts
    - iCloud does not seem to show any contacts to even bring back onto the iMac
    It seems like a really silly thing to have any local data removed AT ALL upon signing out of iCloud. What's on the machine should remain on the machine unless the enduser literally goes out of there way to purposly delete the information stored there. There should be no dialog box what so ever even indicating that data will be removed, and even if the data was removed there should be an easy way to undo the action in case the enuser misinterpreted the action. Before any of the data is removed from the local the information (or at least a copy of it) should have been automatically stored to the cloudspace PRIOR. Why on earth would Apple set it up in such a way where the default is to delete any local data at all?

    No. Absolutely not. We'll just have to agree to disagree. iCloud should be able to be turned on or off on any given device associated with said account. Local stores should be synchronized and that synchronization should happen continuously if connected. When not connected, local stores should maintain their state. What would be the purpose of even bothering to "sync". Or are you saying that in effect everything is copied to a central location (ie the cloud) and any devices wanting access to that data need to be "signed in", and in effect becoming nul terminals with no local store? Why should the default assume users would want to delete the synchronized data upon sign out?  iCloud should be a "use as needed" tool and not an "either/or" tool. In this case *it* should have backed the data up to begin with. That is the purpose after all. I (wrongfully) assumed in haste that the information was backed up or copied elsewhere and that even if I chose to delete it from the local device, I would still have access to it because it was stored "somewhere". And if the data wasn't synced/backed up to "the cloud" upon sign-in, then a friendly reminder alerting the user that now data had yet been saved would certainly go a long way. But this derails the entire thread. All I want to know is whether or not there is a way to retrieve the data that was erased from the iMac?

  • Format of files for calendar, tasks and address book to export/sync

    My idea is to sync the files that are used by TB/Lightning, to manage my calendar, tasks and the address book.
    My question is, in which files calendar, tasks, address book are saved and which format do these have?
    Do I NEED to export each of them, before managing them with another software? (Icedove and possibly Android)

    When you export your calendar, it is in an .ics file, both events and tasks. The ics file is a text file which can be edited. RFC-5545 defines the format.
    When you export your address book, there are two formats: CSV is comma separated variables, and can be input to a spreadsheet. LDIF is also a text file and is better for importing into another computer.
    As far as syncing, I'm not sure what you have in mind, but Google is one way to share that data between devices.

  • What is the best way to backup Address Book to external HD?

    Hello there
    I would like to backup my Address Book on an external HD. How do I go about doing and what's the best way to doing it?
    I have a vague idea but not sure if it's the correct folder to drag to the external HD. I went to ~/Library/Application Support/Address Book. My question is this: Is that Address Book folder the correct one to drag to the external HD? Am I missing other important folders to drag along to the external HD in order for both the Address Book folders to be the same in my internal and external HD?
    Thanks in advance!!

    It would copy the information into a single file... The same as if you wanted to share your contacts with someone else-you could email the vCard to them, they would import it and have the all the same contact information imported into their address book.
    For your own use, it's pretty much the same and works through the File>Import>vCards option in AddressBook.

  • How to Re-Install Address Book Please?

    When i open AddressBook it only shows me a blank grey box. It locks up when i click System Preferences. When i use the Address Book Widget i can search my addresses. But i cannot see the Address Book Application.
    Please tell me how to re-install Address book. I tried the MacOSX Tiger disk and run the Adressbook.pkg but it says there is nothing to install.
    Is there no simple Address Book download?
    Help please

    What locks up when you click System Preferences?
    Is the Address Book application in your Applications folder? (The main one, not the one in your home folder)
    What happened before it stopped working?
    How are you starting Address Book?
    If it does need reinstalling you should be able to do it as an optional installation from your installation DVD. Make sure to run the appropriate Combo updater afterwards, to bring it back up to date.
    AK

  • Upgrade to 10.8.2 lost ical,ichat and address book. Where did they go?

    A recent os upgrade to 10.8.2 has left my desktop without ical, ichat and address book icons. Question marks reside where they use to be. i'm unsure how to procede.
    Thanks for any help on this.

    Well, first, of course, in Mountain Lion they're called Calendar, Messages and Contacts. So if you search, use those terms (however, searching using "iCal" etc should still locate them).
    But the first thing to do is check in your Applications folder. Open a Finder window, click on your Applications shortcut and look for them there. You can drag them from that folder to the Dock to make shortcuts.
    If you can't get there, try using Spotlight (the magnifying glass icon at the top right of the screen). You can launch the app from the result list in Spotlight then, when it's running, right-click on the icon in the Dock and click Options - Keep in Dock to pin it there.
    Matt

  • Recovering emails, address book, etc from old hard drive

    I have had a motherboard crash. My data still exists and is accessible if i hook the old drive up as an external drive on another system. Old Op sys is xp media addition. Bought new system with windows 7. I can locate the email profile in the app data folder on the old drive but copying it into the new systems profile folder did not work. Thunderbird acted like i was setting it up for the first time. On the old drive I can see files that correspond to email folders i had previously and it appears that the emails still exist due to the size of the files. It took several minutes to copy the profile folder to a flash drive. If i click on a thunderbird folder on the old drive the system asks what program i want to use. i steer it to thunderbird and a window opens like i want to send an email. I took the old drive and made it the boot drive in another system. It booted but when i opened thunderbird it acted like there was no profile at all. Started asking questions like it had never been set up on an email account before. From what you see here is it still possible to get either my emails, or at least my address book back?
    Question 2. is it not the law now that all companies keep an archive of emails for a certain length of time? 3 or 5 years? Might i be able to get them to release the archived emails back to me?

    I don't have any personal experience with Thunderbird. There actually is a separate support site here: https://support.mozillamessaging.com/en-US/home

Maybe you are looking for

  • Where to find my subtitels of a rented movie?

    I rented 2 movies. First one had dutch subtitels without any problem. Now i want to watch "the iron lady" and i can't find any subtitels. In the itunes store it was clearly marked that there were subtitels in dutch... How can i find the subtitels and

  • How do i store things to a flash drive

    Hi I'm a bit of a newby when it comes to using a Mac.  I'm finding it difficult to add things to my flash drive, when I insert the drive it doesn't seem to register or am I missing something? My question is how do I put films, text etc to the flash d

  • File Upload not working in table popin

    Hi experts, im using file upload in the table popin, when i click the browse button, its not opening the file-open dialog. please help me. regards, James

  • What to do if it all goes wrong

    what to do if it will not boot after you have overclocked it CLEAR CMOS  Clear CMOS Guide to what assaf has said i will add after unplugging it and before moving the jumper press the pc's start button this will run the fans and use up and storred pow

  • Reinstallation and Microsoft Office

    Hi! I want to reinstall my OS to clean my harddrive however, I fear losing the Microsoft Office that came with my MacBook when I bought it from school. Is there any way to wipe my harddrive, while saving Microsoft Office?