Search code examples
macoslabelapplescript

AppleScript - Finder set label with absolute path


I have this working AppleScript that sets a label. But it asks me to select the file.

Question: how do you specify a path to the file that you want to change the label index to, so you aren't prompted

set myPath to (choose folder with prompt "choose")

tell application "Finder"
    set label index of myPath to 2
end tell

Solution

  • Try this :

    set myPath to "/Users/John/Desktop/Somefile" as POSIX file as alias
    
    tell application "Finder"
        set label index of myPath to 2
    end tell