Set a shortcut to a file using AppleScript

I am trying to put a color mark in a file using 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 terminal with osascript theScript.scpt, I get the following error:

theScript.scpt: 144: 178: runtime error: Finder received an error: cannot set the file label of the document "file.ext" in the folder "folder" to the "Path" folder of the boot disk to 3. (-10006)

Any ideas why I am having a problem and how can I get it to work?

+3
source share
1 answer

It should be encoded as label indexnot a label, and it should be alias:

set theFile to "HDD:Path:to:the:file.ext" as alias
tell application "Finder" to set label index of theFile to 3
+7
source

All Articles