Re: Counting & trashing
Re: Counting & trashing
- Subject: Re: Counting & trashing
- From: Nigel Smith <email@hidden>
- Date: Tue, 13 Jul 2004 14:04:35 +0100
On 13/7/04 11:50, "Walter Ian Kaye" <email@hidden> wrote:
>
--###sort flist based on creation date;
>
--###i leave this bit to those who have written sorting routines.
>
--assuming flist_sorted output:
Of course, you don't need to sort the entire list, you can just get the
oldest few.
If you do want a sorted list of folder names, then
set theList to every paragraph of (do shell script "ls -t " & POSIX path
of alias "path:to:folder")
...would be good for OSX users.
For those who don't like "do shell script", here's another option which
returns a list of the names of items other than the youngest 15 items, which
you can then concatenate with the path to the enclosing folder for the
deletion step. I've done it as a script to run from a script editor to show
the logic:
tell application "Finder"
set {l1, l2} to {name, modification date} of every item <linebreak>
of (choose folder)
end tell
set oldestList to {}
set lastOldest to date "Thursday, January 1, 1000 0:00:00"
repeat while (count of l1) - (count of oldestList) > 15
set tmp to item 1 of l2
set oldestIndex to 1
repeat with x from 2 to count of l2
if item x of l2 < tmp and item x of l2 is greater than <linebreak>
or equal to lastOldest then
set tmp to item x of l2
set oldestIndex to x
end if
end repeat
set end of oldestList to item oldestIndex of l1
set lastOldest to item oldestIndex of l2
end repeat
return oldestList
Does anyone have a way to hard-code a date earlier than 1/1/1000?
Later,
Nigel
_______________________________________________
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.