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.
Way to read the Spotlight comment in Automator workflow
automator
Related Question
- MacOS – Folder action acts on files not specified in the workflow
- How to create an Automator service to run a script on all files in a folder
- MacOS – Wanted: Apple Script for copying file name and pasting it in Spotlight Comment box Mac OS X 10.8.5
- AppleScript – How to set variables for an undetermined number of list items
- How to deploy Automator workflow to clients
Best Answer
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:
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:
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.