Address Book contacts names in capital letters ?

Hello,

I would like to ask if there is a quick method that I can use in order to change all the contacts names in my address book to appear in capitals at once. I am asking this because I have almost 300 contacts and it will take me many hours to do it one by one.

Thanks in advance.

Chris.

Model: iMac 3.06 GHz, Intel Core 2 Duo
Browser: Safari 533.17.8
Operating System: Mac OS X (10.6)

Hi,

try this


tell application "Address Book"
	script a
		property l : get people
	end script
	
	repeat with aPerson in a's l
		set {first name:fName, last name:lName} to aPerson
		if fName is not missing value and (ASCII number (first character of fName)) > 96 then set first name of contents of aPerson to my capitalize(fName)
		if lName is not missing value and (ASCII number (first character of lName)) > 96 then set last name of contents of aPerson to my capitalize(lName)
	end repeat
end tell

on capitalize(n)
	say "here"
	do shell script "echo " & quoted form of n & " | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1'"
end capitalize


Hello Stefan and thank you very much for your reply.

I did run this script with my Apple Script Editor but when it finished nothing in my Address book had changed. None of my contacts names was in capital letters.

Did you try it and it worked ?

Sorry, I overlooked that you’re running Snow Leopard. It requires to save the address book explicitly
Just add the save command at the end of the application tell block


.
save
end tell
.

Heloo and thanks for your reply.

I did motify the script you send me but after running it i get a missing value error in the event log.
I dodnt know many things about scripts and code so i beleive that i am not doing something correctly.

Can you please send me the complete script corrected.

Best Regards

Chris

save addressbook is still better


tell application "Address Book"
	script a
		property l : get people
	end script
	
	repeat with aPerson in a's l
		set {first name:fName, last name:lName} to aPerson
		if fName is not missing value and (ASCII number (first character of fName)) > 96 then set first name of contents of aPerson to my capitalize(fName)
		if lName is not missing value and (ASCII number (first character of lName)) > 96 then set last name of contents of aPerson to my capitalize(lName)
	end repeat
	save addressbook
end tell

on capitalize(n)
	say "here"
	do shell script "echo " & quoted form of n & " | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1'"
end capitalize

Missing Value error again… :confused:

I am running the script you are sending me from the Open this Scriplet in your Editor: option of the forum.

Sorry but something is wrong. Did you try it and it works in your system ?

Yes, I tried it (on Leopard) and it worked.
Of course you must remove the say line, I used it only for debug purpose

So can you please send me the script without the say line command ?

Sorry but i tried to edit it and i got various erros.

I cant make it work…

just open the script above again and remove the say line, compile it and run it

Ok i did remove the say line and then hit compile.

It runs but after a while it stops giving me this missing value error.

This is what i Compile and Run.

tell application “Address Book”
script a
property l : get people
end script

repeat with aPerson in a's l
	set {first name:fName, last name:lName} to aPerson
	if fName is not missing value and (ASCII number (first character of fName)) > 96 then set first name of contents of aPerson to my capitalize(fName)
	if lName is not missing value and (ASCII number (first character of lName)) > 96 then set last name of contents of aPerson to my capitalize(lName)
end repeat
save addressbook

end tell

on capitalize(n)
do shell script “echo " & quoted form of n & " | awk ‘{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1’”
end capitalize

can you see which line is highlighted and what is the error message?

I have a picture with the script compiled runned and the error when it stops.

It just says missing value with blue letters. I dont see anything highlighted.

Is there a way to send you the picture? I searched the forum but it doesnt seem that members are allowed to upload images here.

you can’t upload images here on MacScripter. You need some own webspace (like dropbox) or a service

Ok i did a dropbox account and i uploaded 2 images with what i tried.

Please let me know what you think.

Here are the links:

http://dl.dropbox.com/u/10402031/Address%20Book%20Script%20with%20error.jpg

http://dl.dropbox.com/u/10402031/Address%20Book%20Script%20with%20error%202.jpg

Thanks

Chris.

The first image is no error message, the displayed missing value is just the result of the last executed line.
In the second image the error message says that the on capitalize() handler is missing.

So in the first image option i have to wait to finish ? It doesnt stops ?

What do you suggest to do to fix it ? Because as i see it wtops and doesnt work after the missing value message…

Yes, it could take time if you have a hugh amount of contacts.
The script has stopped when the Stop button is greyed out

Yes when i get the missing value message the Stop button is grayed out…

Sorry but it doesnt seem to work for me.

Then the script has finished. You don’t get any message unless you wrote one.
Are the appropriate contacts capitalized now?