• 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: Finding the oldest date in a list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding the oldest date in a list


  • Subject: Re: Finding the oldest date in a list
  • From: Emmanuel <email@hidden>
  • Date: Wed, 19 May 2004 21:59:11 +0200

At 4:14 PM -0400 18/05/04, Steven Valenti wrote:
>I would like to find the oldest date in a list but just can't seem to
>think how to evaluate all of the items. Can anyone help? The items in
>this list are names of folders that were created in a backup script and
>after 5 days I need to delete the oldest backup.
>
>set BackUpFolder to {"5/11/2004", "5/12/2004", "5/13/2004",
>"5/14/2004", "5/17/2004", "5/18/2004"}
>set FirstDate to item 1 of BackUpFolder
>set SecondDate to item 2 of BackUpFolder
>date FirstDate < date SecondDate

If you use OSX maybe the simplest is:

-------------------------
set x to {"5/11/2004", "5/12/2004", "6/14/2004", "5/17/2004", "5/13/2004", "5/18/2004"}
set text item delimiters to return
text items of (do shell script "echo " & x & " | tr '\\r' '\\n' | sort -t / -n -k3 -k1 -k2")
-- {"5/11/2004", "5/12/2004", "5/13/2004", "5/17/2004", "5/18/2004", "6/14/2004"}
-------------------------

Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


References: 
 >Finding the oldest date in a list (From: Steven Valenti <email@hidden>)

  • Prev by Date: Re: Print to PDF
  • Next by Date: new venerability on macosxhints through Safari
  • Previous by thread: Re: Finding the oldest date in a list
  • Next by thread: Re: Finding the oldest date in a list
  • Index(es):
    • Date
    • Thread