Re: Jeez, I must be very stupid... (Filtering a list of items...)
Re: Jeez, I must be very stupid... (Filtering a list of items...)
- Subject: Re: Jeez, I must be very stupid... (Filtering a list of items...)
- From: has <email@hidden>
- Date: Wed, 30 Oct 2002 11:34:45 +0000
Michael Cytrynowicz wrote:
>
tell application "Finder"
>
get every item of desktop whose kind is not "volume"
>
end tell
>
>
Am I stupid, or have I found the solution? Please tell me...
AppleScript is stupid. Finder is stupid. You ain't stupid. Here's why:
What we _really_ want is to filter by class, since class never changes.
Alas, this is hopelessly _broken_, so a substitute solution has had to be
found.
Filtering by kind was one of the first things tried. But Gakuji Ohtori
pointed out the value of 'kind' changes depending on OS version and
language. Using a literal string ("Volume") as you do above means the
filter won't work on non-English, non-OS X systems. This isn't obvious if
you've never worked on different systems, but the aim of the thread was to
find a general solution that would work on any system.
Shane Stanley described a reliable approach to filtering by kind: ask the
system what string it's currently using for kind:
tell application "Finder"
get every item of desktop whose kind is not (get kind of startup disk)
end tell
This neutralises the portability problem, though is probably not the first
thing most folks would think of.
In the end though, folk kinda felt that filtering out disks probably wasn't
as useful as being able to filter out everything _except_ folders and files
(chances are you don't want Trash and desktop printers included in your
result either). So we end up with something like 'files of desktop &
GetFoldersOfContainer(desktop)'. It sure ain't pretty, but (touch wood)
it's portable and gets the job done.
Yeah, stuff like this ought to be dirt simple (and foolproof). Alas, due to
bugs, glitches, oversights, incomplete implementations, etc. it can
sometimes turn into a right old circus instead. Hopefully the AS/Finder
teams hear of the pain it's causing and can fix it for the next release.
<whew!> Hope that helps,
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.