Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Joseph C

macrumors 68000
Original poster
Feb 5, 2009
1,534
2,978
Hi guys

I used a Facebook to iPhone contact downloader and unfortunately it created about 200 new contacts for whom I do not have a phone number.

Unfortunately iPhone sync does not have the option to only sync contacts with phone numbers :rolleyes: Why not? Anyway:

I'm trying to create an Applescript to delete all contacts who do not have a phone number on their card. Does anyone know if this is achievable?

Thanks. :)
 
Select the contacts in Address Book you want to process and run this script.

Code:
tell application "Address Book"
	
	set lista to selection
	repeat with osoba in lista
		
		if (number of phones of osoba = 0) then
			delete osoba
		end if
		
	end repeat
	save
	
end tell

It gets the list of all selected contacts and repeatedly tells Address Book to check the number of phone numbers for each person from the list, and if that number it is equal to zero, it deletes that contact. Then it saves changes.

However, as iTunes allows you to sync a group selected from the Address Book, you might use this script instead:

Code:
tell application "Address Book"
	
	set grupa to make new group with properties {name:"With Phone Number"}
	
	set lista to selection
	repeat with osoba in lista
		
		if (number of phones of osoba > 0) then
			add osoba to grupa
		end if
		
	end repeat
	save
	
end tell

It creates a new group in Address Book (called "With Phone Number") and copies there all the contacts from the selected ones that have at least one phone number.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.