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 15:45:09 +0000
John S. Baltutis wrote:
>
OK! This works in OS 9.2.2/AS 1.8.3 and rather quickly.
>
>
tell application "Finder"
>
set x to (trash's index & disks's index)
>
set y to name of (every item of desktop whose x does not contain index)
>
end tell
>
>
result-->{" Apple OSX dmg ", "10.2 fixes", "Script Editor"<snip every
>
other thing on desktop that's not the trash or a disk>}.
Yet another clever attempt at a solution. (If nothing else, this thread has
been a testament to the endless ingenuity of AppleScripters in trying to
find workarounds for AS cruddiness.) I took the liberty of changing it
around a little to make it easier to read:
tell application "Finder"
set indexList to trash's index & disks's index
set namesList to names of items of desktop whose index is not in
indexList
end tell
-------
And...
>
tell application "Finder"
>
get every item of desktop whose kind is not "disk"
>
end tell
[...]
>
results: -->{trash of application "Finder", file " Apple OSX dmg " of
>
application "Finder", file "Script Editor" of application "Finder"<snip
>
every other thing on desktop that's not a disk>}
>
>
Every item is identified by type and has "of application "Finder" appended;
>
not exactly what one would want if only the names were desired. Stripping
>
these with TIDS should work, but I'm a newby with those.
Don't panic! That's a list of normal object references you're looking at.
_No_ need for TID Voodoo or other crassness:). If all you want is the
items' names, just ask for 'em:
tell application "Finder"
get NAMES OF items of desktop whose kind is not "disk"
end tell
-------
>
Haven't looked at OS X's behavior.
Believe me, OS X is not without a sense of humour. A really warped, sick
sense of humour. Trust me, you do _not_ want to use this method on Finder X.
[DISCLAIMER: I'm still on OS10.1.5, so for all I know things have been
improved/fixed for 10.2. But until I know this for certain, I'll assume
same-old same-old.]
I don't want to go into the gory details here, but:
1. Trash is no longer represented as a "physical" object within Finder,
appearing only in Dock. Finder's object model hasn't been refactored to
account for this change; hence trash-object still inherits from from item
(via container), but 'unimplements' some of the inherited properties it can
no longer use (index, container, etc.). This is a big fat design sin. The
Finder's object model needs refactored; inserting new classes where
necessary and moving properties and commands around.
2. Disks are no longer desktop elements. Therefore their index values no
longer have any relationship to what's shown on the desktop. Again,
whatever devious hacks and kludges were used to make disks [optionally]
visible on desktop aren't adequately reflected in the scripting model
implementation (which again doesn't seem to know _what_ way it's going).
The only viable solution I can see is for disks _never_ to appear as
elements of desktop in Finder X's scripting object model.
If any OS10.2 user wants to look into this issue further, I'd be happy to
discuss what details I have. I won't get OS10.2 installed before the end of
next month, so there's no point in me making any Radar submissions right
now.
But there's obviously issues that weren't thought out/addressed in
transitioning the Finder and its scriptable interface to OS X. If they've
not been dealt with in 10.2 then they really ought to be brought to the
engineers' attention so they can sort it out asap.
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.