C-Command Software Forum

Refreshing OpenMeta tags

I need to be able to tag files outside EagleFiler (Gravity Applications “Tags” and IronicSoftware “Leap” make setting tags and finding tagged files again so much more convenient than EagleFiler). But EagleFiler has to stay in sync somehow (all my other apps manage this automatically, I don’t know why EagleFiler doesn’t).

I’ve seen this question, modified this script, and produced this:

tell application "EagleFiler"
    set _records to selected records of browser window 1
    repeat with _record in _records
        my reloadFile(_record)
    end repeat
end tell

on reloadFile(_record)
    tell application "EagleFiler"
        set _file to _record's file -- ? need to point to the file
        set _container to _record's container
        tell _record's library document to import files {_file}
        set _newRecord to item 1 of the result
        set _trash to trash of _record's library document
        set _record's container to _trash
        set _newRecord's container to _container
        my copyMetadata(_record, _newRecord)
    end tell
end reloadFile

on copyMetadata(_source, _dest)
    tell application "EagleFiler"
        set _tags to _source's assigned tags
        set assigned tags of _dest to _tags
    end tell
end copyMetadata

but it doesn’t work, telling me error “Can’t get item 1 of {}.” number -1728 from item 1 of {} when it gets to set _newRecord to item 1 of the result.

The EagleScript “Errors” window shows the file getting loaded, but the error comes up that “This file is already in the EagleFiler library”, although I have allowed duplicates in Preferences.

Any reason why I should be getting this error?

These other applications use OpenMeta as their primary tag storage. For a variety of performance and data integrity reasons, EagleFiler stores the tags its own way (although it exports them for other applications to read). Perhaps a future version of EagleFiler will be able to do two-way syncing automatically, although it would require storing additional metadata to determine which tags are the newest.

The error is correct. You’re not trying to import a duplicate; you’re trying to import a file that is, itself, already in the library. That doesn’t make sense, so EagleFiler disallows it.

Some options would be:

  1. Instead of trying to reimport the file, just load its tags from OpenMeta and set them in Eaglefiler. (I’m not sure whether OpenMeta provides an AppleScript-friendly way to get at the tags.)
  2. Make a copy of the file in a temporary folder and tell EagleFiler to import the copy.

With EagleFiler 1.5 there is a new load OpenMeta tags AppleScript command that can be used to replace the EagleFiler tags on a file with the ones from OpenMeta.