• 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: get type of selected finder item
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get type of selected finder item


  • Subject: Re: get type of selected finder item
  • From: Luther Fuller <email@hidden>
  • Date: Thu, 23 Apr 2009 14:11:02 -0500

On Apr 23, 2009, at 1:49 PM, Tobias Exner wrote:

what's the meaning of the following line?

set selectedItem to (original item of selectedItem) as alias

An alias file (has a little arrow at the lower left of the icon) points to a file somewhere on your Mac.

tell application "Finder"
set selectionList to the selection as alias list
if (count items of selectionList) ≠ 1 then
beep
return
end if
set selectedItem to (item 1 of selectionList)
if (class of item selectedItem) is alias file then
set selectedItem to (original item of selectedItem) as alias
end if
if (class of item selectedItem) is not folder then
beep
return
end if
--
-- selectedItem is now an alias to a folder
-- do stuff with it here
end tell

If you have selected a single alias file that points to a folder, then you probably intend that that folder be used in the script. The line that tests if you have selected an alias file replaces 'selectedItem' (an alias (pointer) to an alias file) with (an alias (pointer) to the item to which the alias file points). The item pointed to by an alias file is known in Finder as the 'original item'. It's in the Finder's dictionary.

If you want to use a "Drag & Drop" interface, instead of a "Select & Launch" interface, then your script will also have an open handler that begins ...

on open dropList

'dropList' should behave like 'selectionList' in the script above ... but it does not!
'dropList' is a list of aliases and never contains an alias (pointer) to an alias file, because alias files are automatically resolved to the 'original item'.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >get type of selected finder item (From: Tobias Exner <email@hidden>)
 >Re: get type of selected finder item (From: Luther Fuller <email@hidden>)
 >Re: get type of selected finder item (From: Tobias Exner <email@hidden>)

  • Prev by Date: Re: get type of selected finder item
  • Next by Date: Re: Closing Safari JavaScript alerts and other modal windows
  • Previous by thread: Re: get type of selected finder item
  • Next by thread: Confounded by Folder Action Script (10.5.6)
  • Index(es):
    • Date
    • Thread