reading the "kind" of item

Hi,

I’ve written a script that process a folder full of Excel files. I’ve saved it as an application so that it can process a folder dropped on it.

I wanted to add some error trapping to make sure that only a folder is dropped on it, and not a file.

	
 open (myfolder)
               tell application "Finder"
                  set theKind to name of myfolder
                  if kind of myfolder is "file" then
                    display dialog "This script can only work if a folder containing files is dropped on it"
                     set continueFlag to False 
                  end if
                end tell
 end open

I’ve excluded all the rest of the script for brevity sake.
I will obviously add a whole lot more error trapping later on to exclude non excel files, etc. But I’m stumped at this point.

When I drop a file on the app, I get an error:
Can’t get kind of {alias “The:Path:to:the:file.xls”}.

It’s clear that my script is picking up an alias, rather than the actual file, but how do I get around that? I seem to remember a script posted here that mentioned file vs alias issues, but I can’t find it any more.

Thanks for any help.

Han Solo

The parameter passed to an ‘open’ handler is a list of the dropped items. If only one item is dropped, the parameter’s a list containing one item. As your script stands, you’re trying to get the kind of the list rather than that of the item. The following works with one or many items:

on open dropList
  repeat with thisitem in dropList
    tell application "Finder"
      if kind of thisItem is "Folder" then
        -- do whatever
      end if
    end tell
  end repeat
end open

There are many different ‘kinds’ of file, so you need to test for “Folder”.

This was exactly it!

Thanks.

Han Solo