Tente:
set UnixPath to POSIX path of ((path to me as text) & "::")
Antecedentes: Estou tentando criar um aplicativo applescript simples que iniciará um aplicativo tcl, mas estou ficando preso na primeira parte do script.
Eu preciso pegar a pasta pai do caminho para o applescript. Quando eu executo este código:
set LauncherPath to path to me
set ParentPath to container of LauncherPath
... recebo este erro:
error "Can’t get container of alias \"Macintosh HD:Users:simon:Downloads:folder with spaces:CrossFire-master:CrossFire Launcher for Mac.app:\"." number -1728 from container of alias "Macintosh HD:Users:simon:Downloads:folder with spaces:CrossFire-master:CrossFire Launcher for Mac.app:"
Depois de ler esta resposta , tentei fazer isso:
set LauncherPath to path to me
set RealLauncherPath to first item of LauncherPath
set ParentPath to container of RealLauncherPath
... mas recebi este erro:
error "Can’t get item 1 of alias \"Macintosh HD:Users:simon:Downloads:folder with spaces:CrossFire-master:CrossFire Launcher for Mac.app:\"." number -1728 from item 1 of alias "Macintosh HD:Users:simon:Downloads:folder with spaces:CrossFire-master:CrossFire Launcher for Mac.app:"
Qualquer ajuda ou ideias muito apreciadas. Obrigado antecipadamente!
P.S. Depois de descobrir os problemas acima, o script completo será algo assim:
set LauncherPath to path to me
set RealLauncherPath to first item of LauncherPath
set ParentPath to container of RealLauncherPath
set UnixPath to POSIX path of ParentPath
set launcherCrossFire to "/usr/local/bin/wish " & UnixPath & "/CrossFire.tcl > /dev/null &" -- creat command to launch CrossFire
do shell script launcherCrossFire
ATUALIZAÇÃO: Aqui está o script de trabalho que incorpora a resposta abaixo:
set UnixPath to POSIX path of ((path to me as text) & "::") --get path to parent folder
set LaunchCrossFire to "/usr/local/bin/wish '" & UnixPath & "CrossFire.tcl' > /dev/null 2>&1 &" -- creat command to launch CrossFire
do shell script LaunchCrossFire -- run command
tell application "Finder"
get path to me
set a to container of the result
return (a as alias)
-- Or just get the name of the Parent Container like;
set b to name of a
return b
end tell
Tags applescript