Syncing Tags/Spotlight comments script

Hi

could it be possible for someone to provide a script which :

-puts the tags of an item into the spotlight comments field within the EagleFiler library folder, so that the tags become viewable and searchable in the finder
or better
-syncs the tags with the spotlight comments fields, every time it is launched

it would be very usefull but I have no knowledge in applescripting

thanks

Here’s a script that puts the tags of the records in the frontmost library into the comments:

tell application "EagleFiler"
    repeat with theRecord in library records of library document 1
        set theNames to (name of tags of theRecord)
        set AppleScript's text item delimiters to " "
        my setComment(file of theRecord, theNames as string)
    end repeat
end tell

on setComment(theFile, theComment)
    tell application "Finder"
        try
            set comment of theFile to theComment
        on error
            if length of theComment > 0 then
                display dialog "Could not set comment of “" & theFile's POSIX path & "” to “" & theComment & "”."
            end if
        end try
    end tell
end setComment

On my Mac, the Finder sometimes reports an error when setting the comments of a folder. If you want to ignore the error, you could delete the line that starts with “display dialog”.

Script not working
Michael,

Firstly thanks for this great application. Have been wandering back and forth between DT, Yojimbo and EF for the past month, trying to figure out which one to go with. An unrecoverable Yojimbo database corruption last week knocked that particular application out of the ring. DT appears to be ? years of its next version and sucks in so much memory with large database that I just can’t be bothered. Spotlight/Finder integration is the single varible which I look at now. Thus EF is the winner.

My only concern with EF for the moment is Spotlight integration. Thanks for the script. However after running it my EF tags are nowhere to be seen in the Spotlight comment field of the EF docs in Finder.

Thus:
a) am I missing something with the script. I selected a bunch of them in EF and ran the script from the Applescript menu item.

b) When will the process of copying EF tags to the Spotlight comments box be automated?

Thanks for the great work.

Steve J

I’m not sure what happened, but the above script is no longer working for me. Try changing the first part to:

tell application "EagleFiler"
    repeat with theRecord in library records of library document 1
        set theTags to assigned tags of theRecord
        set theNames to {}
        repeat with theTag in theTags
            copy name of theTag to end of theNames
        end repeat
        set AppleScript's text item delimiters to " "
        my setComment(file of theRecord, theNames as string)
    end repeat
end tell

I’m going to try to get it into the next version, but no promises.

EagleFiler 1.2 automates this process with the new option to Copy Tags to Spotlight Comments.