I need to do some clean up on Spotlight comments. Is there a way to read the Spotlight comment, then set it to another value ? For example let's say I need to remove one specific word in the comments. Adding is easy, with Set Spotlight Comments for Finder Items. I'm looking for the opposite action.


Since it appears that Automator doesn't have a "Get Spotlight Comment" action (surprisingly), maybe you can do this with AppleScript. (See this forum)

Something like:

tell application "Finder"   
    set thisItem to "Macintosh SSD:untitled folder"
    set Comm to comment of folder thisItem (* get comment *)
end tell
return Comm (* to return the Comment string for editing *)

This returns the Comment (in the Get Info Window) of the specified folder on my Desktop, and could be modified to modify the comment of all items passed in by Automator.

In Automator, you'd have to add the action "Run Applescript" and insert a script like this there. Unfortunately I don't think you can have the script take both the files & new comment as input from the previous Automator action. So you'd probably have to hard-code the comment modification part, and add a set comment part, perhaps like so:

on run {input, parameters}

    tell application "Finder"   
        set thisItem to the input as string 
        set Comm to comment of folder thisItem (* get comment *)
        (* manipulate the comment strings*)
        set comment of folder thisItem to "NewCommentString" (* set comment *)  
    end tell
    return input (* to pass the file list to next automator action)

end run

This script currently only modifies a single file's comment - I believe you'd have to loop through the file list to do it on many files. (To make the new comment modifiable at run-time, maybe use "Show this action when run" on the *Run AppleScript" action?). Or you might end up moving the entire script to AppleScript.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .