PhotoLab Keyword Tools

Some clues for how this is done are at https://forum.dxo.com/t/some-database-querying-tools-that-you-might-find-useful/50526.

If you’d like Mac versions of the tools, and have experience with databases, send me a message. I need to have some of the Mac database fields reverse-engineered.

In general:

  • importKeywords and exportKeywords work by reading from and writing to the Keywords table. The getKeywordPaths SQL at the link above will give you an idea of how to read from the Keywords table (and there is a Mac version!)
  • renameKeywords is a more complicated story. As I said in the OP, I had to consider 16 different cases involving renaming, reparenting, and merging. This means that I have to both alter the Keywords table and the KeywordsItems table.
  • findKeywordMatches creates SQL to generate a giant table of all image-to-keyword pairs. The SQL for findImagesWithoutKeywords at the link above will give you a clue to how the query is done. The logical expression given to the tool is parsed and broken down into SQL queries which extract records from the giant table I mentioned and use INTERSECT, UNION, and EXCEPT to support AND, OR, and NOT. The pattern matching is done with the SQL “LIKE” operator.

If you think looking at the code would be a quick path to getting working Mac versions, understand that I can generate Mac versions—it’s just that they would then try to operate on a database with Windows table names and fields, which will not work. You’d still have to reverse-engineer the Mac database fields, and if you can do that, I can generate Mac versions.