背景:我正在尝试编写一个简单的 applescript 应用程序来启动一个 tcl 应用程序,但是我在脚本的第一部分被卡住了。
我需要获取applescript 路径的父文件夹。当我运行此代码时:
set LauncherPath to path to me
set ParentPath to container of LauncherPath
Run Code Online (Sandbox Code Playgroud)
...我收到此错误:
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:"
Run Code Online (Sandbox Code Playgroud)
阅读此答案后,我尝试了以下操作:
set LauncherPath to path to me
set RealLauncherPath to first item of LauncherPath
set ParentPath to container of RealLauncherPath
Run Code Online (Sandbox Code Playgroud)
...但我收到了这个错误:
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:"
Run Code Online (Sandbox Code Playgroud)
非常感谢任何帮助或想法。提前致谢!
PS一旦我弄清楚了上述问题,完整的脚本将是这样的:
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
Run Code Online (Sandbox Code Playgroud)
更新:这是包含以下答案的工作脚本:
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
Run Code Online (Sandbox Code Playgroud)
ada*_*one 19
尝试:
set UnixPath to POSIX path of ((path to me as text) & "::")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19714 次 |
| 最近记录: |