change all address book email field labels from "Email" to "Work"

I have 2500 contacts, most of my email addresses are labeled “Email”, however the .mac address book only shows the email addresses if they are labeled “Home” or “Work”

Can anybody come up with a script to change all email field labels from “Email” to “Work” or “Home”

Model: Macbook Pro
Browser: Safari 522.12.1
Operating System: Mac OS X (10.4)

Hi,

I had a similar script to this for phone labels lying around. With a few modifications:

----
-- Change Address Book's Email Labels
-- John Maisey 
-- 9 September 2007
--- http://www.nhoj.co.uk
-- From similar script written for phone labels 27 May 2005

set theOld to "email" -- label to replace
set theNew to "work" -- new label

tell application "Address Book"
	--to mark time taken 
	set startTime to (current date)
	-- get people whose email labels contain the old term
	set thePeople to (get every person whose label of emails contains theOld)
	-- loop through these people
	repeat with aPerson in thePeople
		-- loop through email entries with the old term
		repeat with myEmail in (emails of aPerson whose label is equal to theOld)
			-- set the label to the new label
			set the label of myEmail to theNew
		end repeat
	end repeat
	-- to refresh
	save addressbook
	--to mark time taken
	set takenTime to (current date) - startTime
	-- Display confirmation
	display dialog "All \"" & theOld & "\" changed to \"" & theNew & "\"." & return & (count thePeople) & " records changed" & return & "in " & takenTime & " seconds." as string buttons {"OK"} default button 1 with title "Change Email Label Script" with icon 1
end tell

Change the lines starting “set theOld to” and “set theNew to” to what you want.

Best wishes

John M

thanks for the reply buddy, I tried your script, it’s getting stuck on

set the label of myEmail to theNew

this is the error that comes up.

Address Book got an error: NSReceiverEvaluationScriptError: 4

Hi,

try


.
-- loop through email entries with the old term
	repeat with myEmail in (get emails of aPerson whose label is equal to theOld)
		-- set the label to the new label
		set the label of contents of myEmail to theNew
.

Thanks Stefan.

The original version works on my system, as it does with your modification. I wish that AS list pointers would work consistently.

waylandchin, did it work for you with the change?

John M

Hi John,

I use always get in the repeat form

repeat with oneItem in (get theItems) .
and also contents, if a value is going to be changed in a list, not just being read

it worked! you guys friggin rock!

I may consider changing the phone number label from “mobile” to “home” or “work” too.

can someone share here
a script with this condition for people in a group :

repeat with people in group =“People”
if email ends with “gmail.com” then set label to “home”
else nothing
end repeat

repeat with for people in group =“company”
if phone number start with “0101” then set label to “home”
else nothing
end repeat

thanks a lot