• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to test if a dropped item (on open) is a file or folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: "Marc K. Myers" <email@hidden>
  • Date: Wed, 03 Jul 2002 13:21:33 -0400
  • Organization: [very little]

> Date: Wed, 03 Jul 2002 08:11:31 -0700
> Subject: How to test if a dropped item (on open) is a file or folder
> From: "Spunk S. Spunk III" <email@hidden>
> To: <email@hidden>
>
> Hi all,
>
> I can't quite figure out the syntax for testing whether a dropped item is a
> file or a folder. Everything I've tried gets an errors "can't get {kind or
> type or class, etc} of [alias] Path:to:my:fileOrFolder". I've tried
> referencing the alias (returned from the dropped item) directly as well as
> "as string" but nothing seems to work. Eg.
>
> on open (filesOrFolders)
> set numOfItems to (count of filesOrFolders)
>
> -- handle only one file/folder being dropped
> if numOfItems is equal to 1 then
> set item1 to filesOrFolders as string -- optional line
> -- if (kind of filesOrFolders ) is "folder" then -- tried this too
> if (kind of item1) is "folder" then
> display dialog "You dropped a folder!"
> ...
> end if
> end open
>
> I've tried a million other variations as well. I need to know if the dropped
> items are files or folders...

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

Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[7/3/02 1:20:44 PM]
_______________________________________________
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.

  • Follow-Ups:
    • Re: How to test if a dropped item (on open) is a file or folder
      • From: Paul Berkowitz <email@hidden>
    • Re: How to test if a dropped item (on open) is a file or folder
      • From: Paul Berkowitz <email@hidden>
  • Prev by Date: Re: Intercepting or preventing a menu choice
  • Next by Date: Re: Remote Access scripting
  • Previous by thread: Re: How to test if a dropped item (on open) is a file or folder
  • Next by thread: Re: How to test if a dropped item (on open) is a file or folder
  • Index(es):
    • Date
    • Thread