获取 AppleScript 的 parent 的 parent 的路径

Get the path of the parent of the parent of an AppleScript

有没有一种简单的方法可以获取 AppleScript 本身的祖父母的路径? 目前我有:

set grandparent to POSIX file (POSIX path of ((POSIX file (POSIX path of ((path to me as text) & "::")) as text) & "::")) as text

这可行,但有点麻烦。特别是当我需要文件的 great-grandparent 时。

试试这个

tell application "System Events" to set grandparent to path of container of container of (path to me)