Re: Newbie: selecting newest file in a folder
Re: Newbie: selecting newest file in a folder
- Subject: Re: Newbie: selecting newest file in a folder
- From: Richard 23 <email@hidden>
- Date: Mon, 23 Apr 2001 07:22:11 -0700
Michelle stated, rather authoritatively 98)
>
Items of a folder are sorted alphabetically, regardless of the creation
>
or modification dates, or the view sort.
Without pausing to consider if he misunderstood her statement,
R23 dashed off a reply in his usual fashion:
I never have found what you seem to have said to be the case.
Here's what the Finder returns when I ask for the name of every
item of one of my volumes:
tell application "Finder" to return name of items of disk 3
{"HTML Editors", " NetWeb Extras", "Core Internet Apps", "site",
"Apple Internet Access", "Browsers", "bubble_trickle.html",
"html", "Incoming", "Index.html", "Installer Logs",
"Internet Search Sites", "OSB Download Logs", "parent",
"richard23", "System Folder Orig", "Utilities", "WebSharing",
"WebSource", "Work", "~Dunno ", "~Misc", "TP2 TrashCache"}
I used the following script trying the various sorting criteria
and none of them seemed to correlate with the order the Finder
returns by default.
-- ---------------------------------------------------------
-- Preprocessed by Convert Script 1.0d5
-- ---------------------------------------------------------
-- author: Richard 23, date: Sunday, April 22, 2001
-- ---------------------------------------------------------
-- uses Programmer's Tool to get Finder list as string list
-- ---------------------------------------------------------
tell application "Finder"
sort items of disk 3 by modification date
set theList to cast (cast result to "STR#")
end tell
set AppleScript's text item delimiters to {":"}
repeat with theItem in theList
if theItem ends with ":" then
-2
else
-1
end if
set theItem's contents to theItem's text item (result)
end repeat
return theList
-- ---------------------------------------------------------
-- by name --
{" NetWeb Extras", "Apple Internet Access", "Browsers", ...}
-- by mod date --
{"System Folder Orig", "TP2 TrashCache", "Utilities", ...}
-- by creation date --
{"parent", "bubble_trickle.html", "WebSource", ...}
-- id of items:
{1655, 38, 521, 96577, 1332, 1029 ...}
-- by kind --
{"Index.html", "richard23", "bubble_trickle.html", ...}
I can't really tell what it's doing, ie, what the default sort
order is that the Finder returns.
If it were by name by default I would probably never use sort
since the result can't be coerced directly to alias list nor
can it be used with whose clauses...since it's not a Finder
reference "name of sort theList by name" doesn't work.
R23