1

我试图在终端中运行一些 AppleScript,只是为了学习如何去做,但我在这个&标志上遇到了一些麻烦。即&使用“&”替换它,它仍然返回相同的错误。我已将其范围缩小到&符号问题,想知道是否有人对此有任何建议。我收到以下错误:

语法错误:预期的表达式,但发现未知标记。

我在终端中输入的代码:

osascript -e 'tell application "Finder"' -e 'set location to (path to home folder as string) & \"testing.plist\"' -e 'if (exists file location) then' -e 'say location' -e 'end if' -e 'end tell'

4

1 回答 1

1

您不需要反斜杠来转义“testing.plist”的双引号,删除它们将修复该错误。

此外,Finder 词典使用了“位置”一词,因此您需要为该变量使用其他术语,例如“myLocation”。

于 2009-07-28T02:37:31.177 回答