通过 applescript 在 Finder 中打开信息窗口

alt*_*ser 0 applescript finder

我在找到正确的苹果脚本命令时遇到一些问题:我想打开给定文件或文件夹的信息窗口。我可以在 Finder 中通过 cmd+i 打开该窗口。现在我希望能够通过脚本文件自动执行此操作。我的代码实际上是这样的:

set aFile to POSIX file "/Users/xyz/Documents/test.rtf"
tell application "Finder" to open information window of aFile
Run Code Online (Sandbox Code Playgroud)

但这是行不通的。错误消息表明文件“Macintosh HD 的信息窗口:Users:xyz:Documents:test.rtf”无法打开。

reg*_*633 5

有些命令对 posix 文件很挑剔。所以我们可以将其强制为其他东西,它会起作用......

set aFile to (POSIX file "/Users/xyz/Documents/test.rtf") as alias
tell application "Finder" to open information window of aFile
Run Code Online (Sandbox Code Playgroud)

或者

set aFile to (POSIX file "/Users/xyz/Documents/test.rtf") as text
tell application "Finder" to open information window of file aFile
Run Code Online (Sandbox Code Playgroud)