Re: filtering a list of items with Finder
Re: filtering a list of items with Finder
- Subject: Re: filtering a list of items with Finder
- From: has <email@hidden>
- Date: Mon, 28 Oct 2002 21:30:40 +0000
Andy Wylie wrote:
>
>did you try the other example...
Alas, my attention was distracted by the pain in all the diodes down my
left side.
>
>set theApp to application "Finder"
>
>
>
>theApp's files & (theApp's items whose class = +AKs-class cfol+ALs)
Sorry bud... good try and all, but in OS X it just leaves another
smouldering crater. (But is this really any surprise?) I _really_ don't
think the whose clause is up to the task (due to bugs/incomplete
implementation/other crap), and trying to hack it is just asking for
trouble.
I'm with JD on this: throw a boring old handler at the stupid thing
already, and get it over and done with. I couldn't care less if it is a bit
slower than a filter reference or whatever, just as long as it _works_.
The following seems ok on OS9.2.2 and OS10.1.5:
======================================================================
on foldersOf(containerObj)
(*
List all folders within a Finder container object
(i.e. disk, folder, desktop, etc. [1])
[1] except trash which is (mostly) broken on OS10.1.5
This is a stinky kludge of a routine that works around
Finder's inability to:
get folders of obj -- (it thinks that disks, trash, desktop
printers, etc. are also folders)
or:
get items of obj whose class is folder -- (whose clauses
just don't work with class)
*)
set resultList to {}
tell application "Finder"
(* Notes:
- since 'folders of' will include other containers
due to Finder's stupidity, a loop + conditional
is used to filter non-folders out.
- 'folders of containerObj' reference must be
explicitly resolved here as AS under OS X
is now too stupid to do anything by itself.
*)
repeat with itemRef in (get folders of containerObj)
if itemRef's class is folder then
set resultList's end to itemRef's contents
end if
end repeat
end tell
return resultList
end foldersOf
tell application "Finder"
get files of desktop & my foldersOf(desktop)
end tell
======================================================================
If anyone can confirm/deny this works under other OS/AS versions it'd be
helpful, thanks.
HTH
has
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
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.