• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Addressbook: delete custom date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Addressbook: delete custom date
      • From: Paul Scott <email@hidden>
References: 
 >Re: Addressbook: delete custom date (From: Paul Scott <email@hidden>)

  • Prev by Date: Re: Adobe Illustrator CS3 'save' command appears to be buggy
  • Next by Date: Re: Set Date & Time Automatically preference
  • Previous by thread: Re: Addressbook: delete custom date
  • Next by thread: Re: Addressbook: delete custom date
  • Index(es):
    • Date
    • Thread