What type is the finder selection?
What type is the finder selection?
- Subject: What type is the finder selection?
- From: Doug McNutt <email@hidden>
- Date: Mon, 12 Aug 2002 14:21:57 -0600
"selection" returns a list of the items currently selected in the finder. How can I tell if they are disks, folders, or files?
*****
** This is where I am:
tell application "Finder"
set theSelection to selection
end tell
repeat with theThing in theSelection
set theType to word 1 of theThing
end repeat
** This is what comes out:
tell application "Finder"
get selection
--> {disk "Hubble", file "Air Traffic.pdf", trash}
get word 1 of disk "Hubble"
--> Finder got an error: Can't get word 1 of disk "Hubble".
Why is finder trying to get word1? I'm outside of the tell block. I expect theThing to be the text 'disk "Hubble"' but it seems to be just "Hubble".
*****
In an on entry block I have some luck with this but it won't behave when any of the selections is a disk.
tell application "Finder"
set theType to file type of theTarget
end tell
if theType is "fold" then -- ignore anything that's not a folder
doInit()
doStuff(theTarget, thePlace)
end if
*****
The word "kind" in the finder dictionary applies only to icons and buttons but just for fun I tried this:
repeat with theThing in theSelection
set theType to the kind of theThing
end repeat
** with the result:
tell application "Finder"
get selection
--> {disk "Hubble", file "Air Traffic.pdf", trash}
get kind of disk "Hubble"
--> "disk"
get kind of file "Air Traffic.pdf"
--> "Acrobat 5.0.5 document"
get kind of trash
--> "folder"
end tell
It almost works except that the "kind" of a file appears to be the name of the creator rather than "file" or something I can reliably test for.
Can anyone point me to a document that contains TRUTH rather than guesses? Should I try asking for the description of theThing? Naah - I get error: Invalid key form.
--
Applescript syntax is like English spelling:
Roughly, but not thoroughly, thought through.
_______________________________________________
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.