Applescript to delete specific Address Book note

I have quite a few Address Book entries with a specific parenthetical note in the Notes field: (Priority).

I’d like to remove “(Priority)” from all the Notes while not removing anything else in Note fields. Is there an easy Applescript to do this?

I’m running Leopard’s Address Book 4.1.

Thanks in advance.

/rb

Hi rogbar,

try this


tell application "Address Book"
	repeat with oneperson in (get people whose note contains "(Priority)")
		set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "(Priority)"}
		set n to text items of (get note of oneperson)
		set AppleScript's text item delimiters to ASTID
		set note of contents of oneperson to n as text
	end repeat
end tell

Brilliant!

How would I modify this script to have it remove ALL the notes? I imported my address book from yahoo, and it placed a bunch of nonsense in the notes filed of each contact. with about 340 contacts, would be nice to have this work for me as well.

Thanks for this little gem!!

Matt

I am looking for a way to add text to multiple AB record note fields without having to copy and paste each one. For example, if I create a group called “My Contacts” and there are 250 records in that group, and I want to add the “sent Christmas Card email 2009” to each note field, is there a way to add the phrase to each note field of the group?

I had been using an Applescript that worked very well. But every since I installed SL 10.6, it doesn’t work anymore. Perhaps the script needs to be altered? If so, how? Here is the script I was using:

tell application “Address Book”
set AppleScript’s text item delimiters to {“Sent Christmas Card Email 2009”}
set TheList to every person of group “My Contacts”
repeat with Who in TheList
if note of Who is not missing value then
set NewNote to note of Who & return & “Sent Christmas Card Email 2009”
set note of Who to NewNote
else
set note of Who to “Sent Christmas Card Email 2009”
end if
end repeat
end tell

an edit to my post at http://macscripter.net/viewtopic.php?pid=127927#p127927

tell application "Address Book"
	repeat with k from 1 to count of people in group "My Contacts"
		set theChoice to "Sent Christmas Card Email 2009"
		set currentNote to the note of person k
		set newNote to (currentNote & return & theChoice)
		if currentNote is missing value then
			set note of person k to theChoice
		else
			set note of person k to newNote
		end if
	end repeat
	save
end tell

I’m still sure there is a more elegant solution !

Val

Hello

I’m currently working with notes in addressbook and I came by this link at macosxhints, which adds the ability to batch add a note to the currently selected addressess. Beware the script uses “;” as its text item delimiter.

Best Regards

McUsr

How would I modify this script to have it remove ALL the notes?

I imported my address book from Outlook and it placed a bunch of nonsense in the notes filed of each contact.

Thanks in advance!

Hello.

This should delete all the notes of all selected persons. Use it at your own risk.
There are plenty of script out there, which deletes Entourages junk.


-- Deletes every note of every person in the address book
-- take a backup first or be sure that you know what your are doing
-- Executing this script is your own responsiblity.
tell application "Address Book"
	activate
	set thePeople to selection
	repeat with thePerson in thePeople
		set note of thePerson to ""
	end repeat
end tell

Best Regards

McUsr

Thank you!!! :wink:

tried the script. It did not remove the notes.

Any suggestions?

It should.
Have you selected some contacts before running the script?

Yes, but maybe I’m not doing something quite right. Do I need to do anything special to enable applescript in AddressBook on 10.6?

I’m opening applescript editor, pasting the script, and telling it to RUN. Address Book is open in the background with all contacts selected.

I remember you must add a save command in 10.6


tell application "Address Book"
	activate
	set thePeople to selection
	repeat with thePerson in thePeople
		set note of thePerson to ""
	end repeat
	save
end tell

That worked like a charm! Thank you! :wink:

Hello.

Ooops. Sorry for that one camcham I didn’t remember that.