Re: Addressbook: delete custom date
Re: Addressbook: delete custom date
- Subject: Re: Addressbook: delete custom date
- From: Paul Scott <email@hidden>
- Date: Fri, 16 Nov 2007 11:02:55 -0800
On Nov 16, 2007, at 2:46 AM, Timothy Bates wrote:
Gosh Paul: thanks for taking the time to figure that out!
Excellent aid - especially when I posted a broken test loop :-)
Thanks again for your help
No problem, it helped clean up my address book. However, I noticed
that after exiting Address Book and opening it again *all* the dates
on the target entries were missing! I did some experimenting, and this
slightly smaller script seems to work better, the *good* dates remain
after restarting the Address Book.
No matter how you slice it, the Address Book scripting is broken.
The delete command should work correctly. This workaround will
certainly break sometime in the future.
In the meantime, if you have problems with the previous script,
try this one instead. It works better for me.
tell application "Address Book"
--ensure you have a person selected, and that they have a custom date
entry
set theProperties to {}
set theList to the selection
set currentPerson to (item 1 of the theList)
set theDates to custom dates of currentPerson
repeat with theDate in theDates
if year of (get value of theDate) ≥ 1920 then
set theProperties to theProperties & {the properties of theDate}
end if
end repeat
if the (count of theDates) > the (count of theProperties) then
set theDate to item ((count of theProperties) + 1) of theDates
try
delete the value of theDate
end try
set i to 1
repeat with obj in theProperties
set theDate to item i of theDates
set theDate's value to the value of obj
set theDate's label to the label of obj
set i to i + 1
end repeat
end if
return theProperties
end tell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden