I'm trying to put a colored label on a file with AppleScript using the following code:
set theFile to "HDD:Path:to:the:file.ext"
tell application "Finder"
set label of file theFile to 3
end tell
but when I run it in a terminal with osascript theScript.scpt
I get the following error:
theScript.scpt:144:178: execution error: Finder got an error: Can't set label of document file "file.ext" of folder "the " of folder 开发者_JAVA百科"to" of folder "Path" of startup disk to 3. (-10006)
Any ideas why I'm having an issue and how can I make it work?
It should be coded as a label index
not a label
and it needs to be an alias
:
set theFile to "HDD:Path:to:the:file.ext" as alias
tell application "Finder" to set label index of theFile to 3
精彩评论