Cal*_*ion 6 applescript finder
我正在尝试制作一个Applescript,它将在不知道硬盘驱动器或用户名的情况下在用户的计算机上打开文件,假设该文件位于用户目录中的相同位置.
tell application "Finder" to open "/Users/jim/Dropbox/Getting Started.pdf" as POSIX file
Run Code Online (Sandbox Code Playgroud)
效果很好,而
tell application "Finder" to open "~/Dropbox/Getting Started.pdf" as POSIX file
Run Code Online (Sandbox Code Playgroud)
失败.
有没有办法简单地完成这个?
dj *_*zie 12
您不能在AppleScript中使用波浪路径,因为POSIX文件实际上是一个URL.文件路径的URL不支持增量路径,仅支持绝对路径.但POSIX路径中波形符的含义并不特别,它只是被主文件夹取代.为了获得相同的结果,我们只需要将您的代码更改为:
tell application "Finder" to open (POSIX path of (path to home folder)) & "Dropbox/Getting Started.pdf" as POSIX file
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6854 次 |
| 最近记录: |