Re: Finding the oldest date in a list
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.