I’d like to shorten procedure of placing file into Adobe Indesign document. So i plan to copy filepath and use in jsx-command “place”. And before this i just select needed file in Finder and run script and would place this path into variable.
You may try :
tell application "Finder"
set thePath to (item 1 of (get selection)) as alias
end tell
When several items are selected they are aliases but when there is a single one, it’s a Finder reference so I coerce to alias which is OK in every case.
Yvan KOENIG (VALLAURIS, France) vendredi 26 décembre 2014 16:30:28
Hello Yvan,
this behavior has been changed in Leopard (or maybe even in Tiger).
selection returns always a list of Finder specifiers or an empty list
Hello Stefan
Oops !
The code which I used before posting was a long one in which the returned selection was explicitly coerced into a list of aliases.
I missed the instruction between two lines of comments :rolleyes:
Yvan KOENIG (VALLAURIS, France) vendredi 26 décembre 2014 23:56:47
Hi,
I’m using this to get the UNIX or OS X path ready for pasting anywhere.
You can use just the variable “myItemPath” or, make a droplet or, make a service with the Automator.
tell application "Finder"
activate
set mySelection to selection
set myItemName to name of item 1 of mySelection
display dialog "This is the Selected Item:" default answer myItemName with title ¬
"Get the UNIX or OS X Path of the Selection" buttons {"Cancel", "UNIX", "OSX"} default button 3
set myChoice to button returned of result
end tell
if myChoice is "UNIX" then
set myItemPath to (POSIX path of (mySelection as text))
else if myChoice is "OSX" then
set myItemPath to mySelection as text
end if
tell current application
activate
choose from list myItemPath with prompt "This is the path to be copied to the clipboard:" with title ¬
"The Path of the Selected Item" with empty selection allowed -- this is just for checking
if result is false then error number -128
set the clipboard to myItemPath
end tell
Why not use the AppleScript command “place”?
Cause i know javascript much better (((
but i’ll try this way also. Thanks