Re: Addressbook: delete custom date
Re: Addressbook: delete custom date
- Subject: Re: Addressbook: delete custom date
- From: Timothy Bates <email@hidden>
- Date: Fri, 16 Nov 2007 10:46:45 +0000
- Thread-topic: Addressbook: delete custom date
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,
Tim
> From: Paul Scott <email@hidden>
> Subject: Re: Addressbook: delete custom date
> On Nov 14, 2007, at 3:16 AM, Timothy Bates wrote:
>> Does anyone know of a work around for this bug (can't delete custom
>> dates)
> The delete command doesn't seem to work on the custom date directly.
> However, I found that it's possible to delete the custom dates *after*
> a given index. With that possibility comes a workaround. The script
> below finds dates with a year < 1920 (your original criteria) and then
> relocates all the following custom dates down one index level. It does
> this iteratively until all dates are processed. Then, if any dates were
> relocated, the delete is done for all those following the last good one.
>
> I tested this on Leopard and it works as follows:
> Input:
>
> Date 1: January 20, 1992
> Date 2: May 20, 2001
> Date 3: July 16, 7
> Date 4: January 14, 1970
> Date 5: August 8, 8
>
> Output:
> Date 1: January 20, 1992
> Date 2: May 20, 2001
> Date 4: January 14, 1970
>
> Here's the script:
> tell application "Address Book"
> --ensure you have a person selected, and that they have a custom
> date entry
>
> set theList to the selection
> set currentPerson to (item 1 of the theList)
> set theDate to custom date of currentPerson
> set n to count of theDate
> set i to 1
> repeat
> if (i ¾ n) then
> set a to item i of theDate
> if year of (get value of a) < 1920 then
> if (i < n) then
> repeat with j from i to n - 1
> set b1 to item j of theDate
> set b2 to item (j + 1) of theDate
> set value of b1 to (get value of b2)
> set label of b1 to (get label of b2)
> end repeat
> end if
> set i to i - 1
> set n to n - 1
> end if
> else
> exit repeat
> end if
> set i to i + 1
> end repeat
> -- delete extra entries
> if n < (count of theDate) then
> try
> set a to item (n + 1) of theDate
> delete value of a
> end try
> end if
> 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