AppleScript and Apple Contacts - fails to delete entries

Running the following AppleScript loop to remove all entries from Mac Contacts...

tell application "Contacts"
	set countPeopleBefore to count of people
	repeat while (count of people) is greater than 0
		set thisPerson to person 1
		delete thisPerson
	end repeat
	set countPeopleAfter to count of people
end tell

Two curious things...

  • countPeopleBefore is greater than 0 and countPeopleAfter = 0, suggesting everything worked fine.
  • Nonetheless all the entries remain in Contacts -- undeleted -- after this script completes.

Questions:

  • Why?
  • Is that a bug?
  • Is there a more effective way to delete all entries in Contacts?

The changes have to be saved after implementation...

tell application "Contacts"
	set countPeopleBefore to count of people
	repeat while (count of people) is greater than 0
		set thisPerson to person 1
		delete thisPerson
	end repeat
	set countPeopleAfter to count of people
	save (*  This line makes the difference  *)
end tell
AppleScript and Apple Contacts - fails to delete entries
 
 
Q