2

I am missing something here to add a comment to a file / folder.

Please help me to figure the missing thing out:

tell application "Finder"

    set filePath to "Macintosh HD:Users:anoopvaidya:Desktop:2.png"
    if exists file filePath then
        --display alert "file:" & filePath
        set comment of filePath to "hi boy"
    end if

end tell

It throws the following error:

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • 1
    You could add the `file` label before `filePath` or declare `filePath` as `alias "Macintosh HD:Users:anoopvaidya:Desktop:2.png"`. The `file` label is obsolet then and it works with folders too. – user309603 Jul 03 '14 at 11:16

1 Answers1

3
set comment of (filePath as alias) to "hi boy"
Michele Percich
  • 1,872
  • 2
  • 14
  • 20
  • thanks a lot man, it worked. :) Now I am gonna implement same thing wrapped in Objective-c to complete [This](http://stackoverflow.com/questions/24548752/how-to-add-comments-in-a-file-and-or-directory-programmatically) – Anoop Vaidya Jul 03 '14 at 11:24