Any script to delete specific website mentioned in "IM" fields in All?

Is there any script to Delete ALL web sites that contain and start with “https://www.facebook.com/profile.php” in the “I’M” field in all of Address Book cards in Address Book for Mac ? if not, can anyone help me in creating one ? new to script…

I downloaded and user The Social Address Book 1.3 and it stewed my address book by adding 5-10 times the same facebook link in the same card.
http://www.macupdate.com/app/mac/39670/the-social-address-book

no backup?

Without ANY guarantees! This might be worse than the illness! It was cooked in the fireplace in a used can.
Save an archive before.


tell application "Address Book"
	repeat with p in every person
		tell p
			set todelete to {}
			repeat with im in every AIM Handle
				if value of im contains "https://www.facebook.com/profile.php" then
					copy id of im to end of todelete
				end if
			end repeat
			if todelete ≠ {} then
				repeat with td in todelete
					delete AIM Handle id td
				end repeat
			end if
		end tell
	end repeat
end tell

Also this works on AIM handles, I am assuming that’s what you mean by “IM” field

@mouramartins Thank You so much for the script :slight_smile: although I did a mistake. It was not the “AIM field” called “AIM Handle” in AppleScript but the “social media” field which I don’t know what is word for it. What should be changed instead ?

This is what needs to be changed:
http://imageshack.us/photo/my-images/137/screenshot20120623at804.png/

Try to replace both “AIM Handle” with “url”

“url” is for the web sites field but the links as show in the picture are in the social media profiles field instead.
What is the proper term for social media profile in applescript ?

even better…what would be a script to delete all “social media links” in all fields in all cards ?

Is there a list where I can fiend how we type all the names of all fields in address book like “url” “aim handle” etc ?

AppleScript Editor → File → Open Dictionary
Click on the Address Book Script Suite

adayzdone, I’m on Lion 10.7.4 and I get this:

I get the following AppleScript Error pop-up:

and in the box at the bottom I get this:

As you can see in the screenshot there is no property value in the element social profile.
Replace value with url

StefanK: Thanks for your kind help.

I now get the following AppleScript error:

In event log it says:

it seems that you can’t delete social profiles with AppleScript in Lion.
I tried (hopefully) every possible syntax.

Last try was


tell application "Address Book"
	repeat with p in every person
		repeat with i from 1 to (count social profiles of p)
			if url of social profile i of p contains "https://www.facebook.com/profile.php" then
				set profilID to id of social profile i of p
				delete (1st social profile of p whose id is profilID)
			end if
		end repeat
	end repeat
end tell


failed too

Anyone else with a solution ?

Hello.

if you google for docs on tools for Address book at Apple Developer, tjem I guess something usable will show up, as the addressbook is used on their servers, as a centralized solution for contact managment, for their customers. So I guess, or think it is an admin tool for addressbook, and that may help you. But I guarantee zip!

Cheers!

I did some search and nothing came up. Did you find anything ? if yes, can you post it here please ? it would really appreciated :slight_smile:

Indeed it’s possible to manage all properties and elements with Objective-C but as the sample projects are created with pre-10.7 environment, none of the sample code provides access to the social profiles element.

As a workaround this script adds the people with a Facebook profile to a new group “facebook” in Address Book,
then you could delete the profiles manually


tell application "Address Book"
	set filteredPeople to every person whose service name of social profiles contains "facebook.com"
	make new group with properties {name:"facebook"}
	repeat with aPerson in filteredPeople
		add aPerson to group "facebook"
	end repeat
	save
end tell

Thanks StefanK for your help the script

Does that mean that all cards with facebook.com are being moved to the “Facebook” group and I will have to manually bring them back to their original groups ?

The original groups aren’t touched. A card can be assigned to more than one group

It says it’s “missing value”

I don’t use FaceBook at all, but I tested it successfully on Lion with a few test cards.
Maybe the real service name doesn’t match “facebook.com

Here’s a screenshot of an Address Book card I have:

I have to delete both “all” Facebook and Twitter social profiles accounts on all cards because they’ve been doubled