Re: How to test if a dropped item (on open) is a file or folder
Re: How to test if a dropped item (on open) is a file or folder
- Subject: Re: How to test if a dropped item (on open) is a file or folder
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 03 Jul 2002 12:26:11 -0700
On 7/3/02 10:21 AM, "Marc K. Myers" <email@hidden> wrote:
>
It's really very easy and doesn't involve either the Finder or a
>
scripting addition. When you look at the path for a folder and a file,
>
what jumps out at you as being different? The folder path always ends
>
with a colon!
>
>
on open(itemList)
>
repeat with anItem in itemList
>
if (anItem as text) ends with ":" then
>
procFldr(anItem)
>
else
>
procFile(anItem)
>
end if
>
end repeat
>
end open
Unfortunately neither your 'colon' method nor my 'info for' method works in
OS X, where the file system knows that cocoa apps - packages - are really
folders. (Thank goodness - it makes it possible to look inside if needed.)
But for simple things, where you want to consider cocoa apps to be "files"
rather than folders that need to be opened, the Finder will do it:
I just checked, The Finder knows the difference, although it refers to a
package app as a "document"! So we'd better not even ask that part of the
question. This seems to work fine. The original questioner ("Spunk") had
seen the term 'kind' somewhere but was using it without the Finder. It is
only defined in Finder tell blocks. This works:
on open(itemList)
repeat with anItem in itemList
tell app "Finder to set theKind to kind of theItem
if theKind is "Folder" then
procFldr(anItem)
else
procFile(anItem)
end if
end repeat
end open
--
Paul Berkowitz
_______________________________________________
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.