Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript to set spotlight comments on multiple files

Hi all;

trying to set some comments on multiple files using an applescript inside automator.

I have an action to select multiple files and then these files are passed to the script:



on run {input, parameters}

tell application "Finder"


activate

set commento to "my comment"

set comment of (input as alias) to commento

return input

end tell

end run


This is working as long as I'm selecting one file only.

Not working with multiple files… Can anybody help me on this please?


(I know this can completely be done with automator without applescript but I need applescript for some other reason so I need to solve the problem this way…)

macBook alu 13"

Posted on Aug 18, 2011 2:05 PM

Reply
Question marked as Best reply

Posted on Aug 18, 2011 3:25 PM

Simple: iterate through the input items:


on run {input, parameters}

tell application "Finder"

set commento to "my comment"

repeat with each_file in input

set comment of (each_file as alias) to commento

end repeat

return input

end tell

end run

4 replies

Sep 29, 2013 4:01 AM in response to intotheappledotcom

To select a list of Finder files then set the comments all at once, run this Applescript:


tell application "Finder"

activate

set fileList to selection


if (count result) is 0 then

try

get (target of front Finder window) as alias

on error

choose folder with prompt "Set comments of files in this folder:"

end try


try

set theFolder to result

set fileList to every file of folder (result) as alias list

end try

end if


display dialog "Comment:" default answer "" buttons {"Overwrite", "Cancel", "Append"} default button 3 with title "Set Spotlight Comments"


set userInput to the result


set newComment to text returned of userInput


if (button returned of userInput) is "Overwrite" then

if (class of first item of fileList) is alias then

set comment of every file of folder theFolder to newComment

else

repeat with thisFile in fileList

set comment of thisFile to newComment

end repeat

end if

else

repeat with thisFile in fileList

tell thisFile

if length of (comment as text) is not 0 then

get ", " & newComment

else

get newComment

end if

set comment to (comment & result)

end tell

end repeat

end if


end tell


---

Thanks to: macscripter dot net/viewtopic.php?id=14199

Applescript to set spotlight comments on multiple files

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.