我正在尝试使用以下代码在AppleScript文件上放置彩色标签:
set theFile to "HDD:Path:to:the:file.ext"
tell application "Finder"
set label of file theFile to 3
end tell
但是当我在osascript theScript.scpt
的终端中运行它时,我收到以下错误:
theScript.scpt:144:178:执行错误:Finder收到错误:无法设置文件夹“file.ext”的文件夹标签“ “文件夹”到“文件夹”“启动盘的路径”到3.(-10006)
为什么我遇到问题以及如何让它发挥作用的任何想法?
答案 0 :(得分:7)
它应该被编码为label index
而不是label
,并且它必须是alias
:
set theFile to "HDD:Path:to:the:file.ext" as alias
tell application "Finder" to set label index of theFile to 3