Re: "Path to" a file
Re: "Path to" a file
- Subject: Re: "Path to" a file
- From: "Marc K. Myers" <email@hidden>
- Date: Tue, 07 Aug 2001 02:44:48 -0400
- Organization: [very little]
I use the following script to create lists of alias references to icons
dropped on it or to the Finder selection:
(*
Alias Reference
I return alias references (as a list) on the clipboard to all icons
dropped on me. This is handy for simulating the way the Finder delivers
the input parameter of a droplet. You just make a temporary run handler
with nothing but "open ()" and paste the list returned between the parentheses.
)Marc K. Myers 2000
*)
on run
tell application "Finder"
set theList to the selection
end tell
open (theList)
end run
on open (theList)
set theText to ""
repeat with anItem in theList
set theText to theText & "alias \"" & (anItem as text) & "\"" &
", "
end repeat
set theText to "{" & ((characters 1 thru -3 of theText) as text) & "}"
tell application "Finder"
activate
set the clipboard to theText
end tell
end open
At 9:56 PM -0400 06/08/01, Greg Back wrote:
>
Hi all-
>
>
I am trying to write a simple script to be run out of OSA menu. The script
>
will get the path to the file selected in the Finder and paste it to the
>
clipboard. (I will use this to help my scripting instead of having to type
>
out long file paths)
>
>
try
>
tell application "Finder"
>
activate
>
set pathTo to file path of selection
>
set the clipboard to pathTo
>
display dialog "The path is on the clipboard."
>
end tell
>
on error
>
display dialog "There is nothing selected."
>
end try
>
>
However, this returns an error of type -49 (if that helps). And the "on
>
error" doesn't work
>
>
I would try "set pathTo to path to selection" but "path to" in Standard
>
additions only appears to work for a limited number of things (applications
>
folder, system folder, desktop, to name a few).
>
>
I know this has been discussed before in relation to applications and
>
certain folders (in the dictionary) but not to a file in general (I think).
>
>
I'm pretty sure that the error doesn't have to do with the clipboard,
as I
>
spent a lot of time studying those dictionary entries: (This from Standard
>
Additions)
>
>
set the clipboard to: Place data on an application9s clipboard. Use
inside a
>
tell9 block and activate the application first
>
set the clipboard to anything -- the data to place on the clipboard
>
>
It *is* in a tell block, and the Finder *is* activated, so I doubt the
>
clipboard is causing the error (I even took out the "set the clipboard to"
>
line). It must be the "path to".
>
>
I know I could create the path using "container folder", etc. but there must
>
be a simpler way.
>
>
Any suggestions???