开发者

Setting a label to a file with AppleScript

开发者 https://www.devze.com 2023-03-10 11:49 出处:网络
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\"

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
0

精彩评论

暂无评论...
验证码 换一张
取 消