UPDATE: I’ve tweaked the scripts from those first published to deal with how spaces are treated in the Subject keyword list. Namely, each keyword should be separated by a comma and a space.

Skylum Software just released a performance-focused update to Luminar 3 that has addressed the biggest pain point for me — it now performs well enough to allow my creative train of thought to flow while processing photos. However, it still does not have a facility to view or edit keywords. Not to worry, though, because I solved that with a good dose of geekery.

The first problem to solve was getting the keywords out of Lightroom. That’s easy enough, as there is an export feature built in, but the output is not entirely useful for hierarchical keywords.

Agusta Westland
Air Tractor

While the structure is visible, copying an entire hierarchical path would be a nightmare. What was needed was for each line to include all the preceding tags from the hierarchy, like this.

Agusta Westland
Agusta Westland,A109
Agusta Westland,A109,NZ3401
Agusta Westland,A109,NZ3402
Air Tractor
Air Tractor,AT-402B

While this still contains extra lines (I would never use the fourth-to-last line), it does provide an easy means of copying a whole line in one go to get the full hierarchy of keywords. Unfortunately, at this time, I don’t have a how-to for getting from A to B here, as the process was long winded and complicated. I’m still looking for a simpler way.

The second problem to solve is how to apply keywords to my photos. I knew straight away that I would use ExifTool to do the job, as I had used it a while ago to investigate how Lightroom was storing its keywords, but figuring out the precise mechanism took me a while longer.

As mentioned in my post on contact sheets, I have HomeBrew, with which I installed ExifTool. Next was what to use as the front end. Again, taking a cue from the contact sheet solution, I chose to create a Quick Action for Finder.

The workflow takes a collection of image files as input — the images you wish to add keywords to. This input is stored away while the user is prompted for the keywords to add. Because I heavily use keyword hierarchies, I have set this up to ask for a single hierarchy. Others may find it more useful to adapt this to a simple list of keywords. The hierarchy should be entered as a comma-separated list, from root to leaf. E.g. New Zealand,Wellington,Tawa. The input keywords are written to a text file /tmp/newtags.txt before being reprocessed additional files.

sed 's/, /,/g' /tmp/newtags.txt | tr -d '\n' >/tmp/newtags_t.txt
sed 's/,/|/g' /tmp/newtags_t.txt | tr -d '\n' >/tmp/newtags_h.txt
sed 's/|/, /g' /tmp/newtags_h.txt | tr -d '\n' >/tmp/newtags_s.txt

This bash shell script does several things. The first line ‘tightens’ the keywords by removing any single spaces following a comma. The second converts that comma-separated list into a pipe-separated list, and the third converts that back to commas but with an enforced space after each comma. All this is due to the way Lightroom stores its keywords in two places.

 A321neo, Air New Zealand, Airbus, NZWN, ZK-NNA, air operator, aircraft, airfield
Hierarchical Subject:
 air operator|Air New Zealand, aircraft|Airbus|A321neo|ZK-NNA, airfield|NZWN

You can see all keywords in Subject have spaced commas and the Hierarchical Subject contains comma separated hierarchies, each pipe-separated. With all that done, the original input list of files is retrieved and passed to another bash shell script which does the magic.

for file in "${@}" ; do
  /usr/local/bin/exiftool '-Subject+<=/tmp/newtags_s.txt' '-HierarchicalSubject+<=/tmp/newtags_h.txt' "${file}"
  osascript -e "tell application \"Finder\" to delete POSIX file \"${file}_original\""

For each file in the list, the new tags are applied to Subject and Hierarchical Subject using ExifTool’s additive operator from the files previously created. ExifTool creates a backup of the original file, which is a good thing, but I don’t want those littering the directory, so the second line inside the loop uses an AppleScript command to place each one in the trash. You should check your files after tagging and if you have any problems, retrieve those trashed files and rename to remove the suffix.

That’s it! An easy way to add keywords in the same manner as Lightroom, but directly from the Finder.

Finally, because I was having to run a lot of iterations to perfect the actions, I needed a way to clear out existing tags. This is a much simpler action using just a variation on the final script from the Add action.

for file in "${@}" ; do
  /usr/local/bin/exiftool -Subject= -HierarchicalSubject= "${file}"
  osascript -e "tell application \"Finder\" to delete POSIX file \"${file}_original\""

Oh, but I forgot. There is one more thing…

Creative Cloud desktop has been successfully uninstalled

Leave a Reply

Your email address will not be published. Required fields are marked *