Lo único en lo que podemos pensar es en un poco de Apple GUI.
Coloque este código en una acción 'Ejecutar Applescript' sobre su acción 'Ejecutar el script de Shell'.
El Applescript está comentado para explicar lo que está haciendo. Pero ten en cuenta que este código es para empezar.
Funciona en mis pruebas.
TENGA EN CUENTA QUE ESTA ESCRITURA FUNCIONA CUANDO LAS WINDOWS ESTÁN EN LA LISTA DE VISTA
Pero no si selecciona un elemento en una lista que está realmente debajo de otra carpeta. Es decir, el revelador de la carpeta apunta hacia abajo y ha seleccionado un elemento dentro de ella. Obtendrás un error.
set thePaths to {} -- empty list
(* NOTE THIS SCRIPT WORKS WHEN THE WINDOWS ARE IN LIST VIEW *)
tell application "Finder"
activate
set theWindows to target of windows -- get the windows target paths
repeat with i from 1 to number of items in theWindows -- repeat for each window
set this_window to item i of theWindows -- get window #n
set thisSelection to my getSelected(i) as string -- run sub routine and pass the item count as the arguments
set thePath to POSIX path of (item thisSelection of this_window as alias) -- convert the path to unix style path
copy thePath to end of thePaths -- add to list
end repeat
end tell
Return thePaths
on getSelected(i)
set theRowSelection to "" -- declare variable
tell application "System Events"
tell process "Finder"
set theRowSelection to value of text field 1 of UI element 1 of ((rows of outline 1 of scroll area 1 of splitter group 1 of window i) whose value of attribute "AXSelected" is true) -- get the selected item by using the attributes of the window - WHICH HAS THE SIDE BAR SHOWING
if theRowSelection is {missing value} then -- THE SIDE BAR SHOWING WAS NOT SHOWING SO THE scroll area 1 NEEDS TO CHANGE TO scroll area 2
set theRowSelection to value of text field 1 of UI element 1 of ((rows of outline 1 of scroll area 2 of splitter group 1 of window i) whose value of attribute "AXSelected" is true)
end if
end tell
end tell
return theRowSelection -- return the selected item name
end getSelected