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

Find & Replace Spotlight Tags?

Hello all,

I was just wondering if anyone knew of a way to use applescript to find and replace terms within the spotlight tags of a bunch of files?

We sent a whole load of footage to be filed and spotlighted and it came back with a few consistent spelling mistakes in the spotlight terms so it would be good to be able to find and replace these quickly with an applescript.

Thanks,
Chris Travis

Mac Pro, Mac OS X (10.5.5), 2 x 3Ghz Quad-Core Intel Xeon, 8GB RAM,

Posted on Dec 12, 2008 2:39 AM

Reply
4 replies

Dec 12, 2008 3:37 AM in response to Travattack

Hi,

Is it the Spotlight Comments you get when you 'get info' on the file in Finder? If so, select all the files you want to modify in the Finder and run this script:

tell application "Finder"
set txt to "John M's file comment text replacement"
set wrongText to text returned of (display dialog "The text to be replaced:" default answer "" with title txt)
set rightText to text returned of (display dialog "The replacement text:" default answer "" with title txt)
repeat with thisItem in (get selection)
set comment of thisItem to (my replaceString(comment of thisItem, wrongText, rightText))
end repeat
display dialog "Done" with title txt
end tell

on replaceString(mainText, searchString, replacementString)
set my text item delimiters to searchString
set theList to text items of mainText
set my text item delimiters to replacementString
set theReturn to theList as text
set my text item delimiters to {""}
return theReturn
end replaceString



Best wishes

John M

Dec 12, 2008 4:45 AM in response to John Maisey

Wow, thanks John.

I've just been going through an introductory tutorial for applescript and I must say it's pretty daunting but I'm definitely going to stick with it.

Thanks a lot for this, I have saved it as an app and sent it to the poor lady who's job it is to correct all the mistakes. She will probably want to kiss you for this.

Thanks again,

Chris

Dec 12, 2008 9:40 AM in response to John Maisey

Indeed, it did not work when I sent it via email.

But I gave her a quick walk through on copying the script, pasting it into the editor and then saving it as an app on her computer and it seems to be working fine. She has put it into the Finder toolbar so she can easily select files, then click on the icon and away she goes.

Thanks again,
Chris

Find & Replace Spotlight Tags?

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