Spotlight comments to openmeta tags

Hey together :slight_smile:

I’m new to this board and I want to discuss my first working applescript below.

What does the script do?

The variable “theFile” has a filepath to a file I would like to tag with openmeta tags.
The script uses the file comments of this file (comma separated) and runs the openmeta commandline tool to tag the same file with every word from the file comments.

I would like to know if this way is okay, or if I can make this script better. :slight_smile:

I think i don’t have to run the command line for every single tag, I think it’s possible to do this just with one command, but at the moment I don’t know how to do that. Or better how to convert the comma seperated comments.


set openmeta to "/Applications/openmeta/openmeta"

tell application "Finder"
   set theFilename to (name of theFile) as string
   set theFileComment to the comment of theFile
end tell

set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {","}}
set myList to text items of theFileComment
set AppleScript's text item delimiters to myTID

repeat with myItem in myList
   set theTags to do shell script openmeta & " -a " & myItem & " -p " & quoted form of POSIX path of theFile
end repeat

Thanks so much

Jamest

so:

set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"\" \""}}
set myTags to myList as text
set AppleScript's text item delimiters to myTID

...

set theTags to do shell script openmeta & " -a \"" & myTags & "\" -p " & quoted form of POSIX path of theFile


Untested!

Happy tagging!

edited an error: AppleScript’s text item delimiters, {“" "”}