"Path to" a file
"Path to" a file
- Subject: "Path to" a file
- From: "Greg Back" <email@hidden>
- Date: Mon, 06 Aug 2001 21:56:43 -0400
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???
TIA,
Greg
PS. OS 9.0.4, AS 1.4.3