Enter controlled vocabulary terms with just a few keystrokes in any Photo Mechanic field that has a flyout menu
In Photo Mechanic and Photo Mechanic Plus, you can use the Autocomplete type-ahead feature to enable a controlled vocabulary right in your Keywords field.
In my last post, I entered a keyword for the name of my cat Donut by typing just three characters – “Don[enter]”.
I have my Structured Keywords controlled vocabulary available through type-ahead in the Keywords field in either the IPTC Editor or the Template Editor. I have saved myself from countless self-inflicted typos as well as enforced my controlled vocabulary. Or at least I know when I’ve veered off the CV straight and narrow.
Watch the video version of this post
Set up Autocomplete
To set up Autocomplete for your Keywords, go to Edit > Settings > Set Autocomplete… Tick the tickbox for “Autocomplete when I type:…” Now choose how many letters you want to type to trigger Autocomplete. I chose three, but season to your taste.
Next, at the bottom of the Autocomplete dialog, tick the tickboxes for “IPTC/XMP field lists” and “When editing IPTC fields, only allow completions from field’s own list”
Now, when you type the first n letters of a keyword in the Keywords field, the matching keyword from your controlled vocabulary will pop up. Just hit [enter] and it’s safely and typo-less-ly inserted in the field. If the first few letters match more than one keyword, a list will pop up. Use the down arrow key to choose and enter. (If you get the list too often, maybe you need to choose a higher number of letters to type to trigger Autocomplete.)
Other fields, too
With this preference set, the same technique will work in any field that has a flyout list, like Country, for instance. If you’re prone to typing transpositions in “Israel” or “Haiti”, this could be a lifesaver.
Where are my keywords?
Where do the values in the Keywords flyout list come from? Well, if you use the Keywords panel dialog, you’ll find that the flyout literally contains your Master Keywords List. Just choose “Edit Keywords…” from the top of the flyout and you can edit, import, save, backup, or do just about anything you want with your Master Keywords List.
Note that if you have your whole controlled vocabulary in your flyout, it will be too long to comfortably use as a flyout. You can, however, with the flyout extended, type a couple of letters and the cursor will drop to the correct spot in alphabetical order. The flyout is case-sensitive. (So is Autocomplete.) Capitalized keywords will appear at the top of the flyout.
What about hierarchical (Structured) keywords?
UPDATE: Can we use this method to add a hierarchical string? In the cat example, every time I add “Donut” to the keywords, “family” and “cats” go too. So, “Donut” is a keyword best served hierarchically.
It can be done. Just add the string to the Master Keywords list and it works. We can do this in the Edit Keywords dialog or in a text editor. Either works.
The trick is to start at the bottom of your hierarchical sequence. In this case, “Donut, cats, family”. If we started at the top of the hierarchy – “family” – the type-ahead would bring up a list of every keyword hierarchically under “family”, potentially dozens of them, and we’d be out of luck.
The order in which the keywords appear is irrelevant. Treating keywords hierarchically is just a way of conveniently adding them. Once they land in the metadata to do their job, all keywords are “flat”. They just lie around in a heap, waiting to be called by a search. So, backwards is fine.
We could even save a couple more keystrokes by adding the trailing comma-space. I just tried it and, upon committing the metadata edit, Photo Mechanic removes punctuation trailing at the end of the keywords string. So, if “Donut, cats, family, “ occurs early in the keywords, adding the comma and space saves us typing them. If it occurs at the end of the string, no foul. Photo Mechanic just zaps the excess punctuation.
Use the CV from Structured Keywords
Now what if you use the hierarchical Structured Keywords dialog and you want to copy your controlled vocabulary from there?
The “Edit Keywords…” dialog accepts a simple text file with one keyword per line. But if you save out your Structured Keywords vocabulary, it’s formatted with a bunch of tabs and brackets and stuff. What to do?
We’ll use a text editor to reformat our Structured Keywords vocabulary to fit the one-keyword-per line format required for the Master Keyword list.
Here, I’ll use Text Edit, the text editor that comes with the Macintosh operating system. For Windows: In Notepad, we delete a tab by selecting one in the text. (It looks like we’ve selected blank space.) Then paste the tab into the Find field, leaving the Replace field blank.
Make a copy. (Text Edit doesn’t have a “Save-as” function. At least not that I know of. We’ll work on a copy.)
UPDATE: Thanks to viewer Bo De Lange, who commented on the video version of this post to tell us that Text Edit does indeed have Save-As. It’s hidden. If you Option-Click on Edit in the main menu, Save-As will appear. Wow. That’s demented! (To put it charitably.) Good to know.
The plan here is simply to use a few passes of Find and Replace to remove all the “structured” formatting from our file.
Zap
First, we’ll zap the tabs.
In Text Edit, go to Edit > Find > Find and Replace… Now click in the “Find” field (on top) to highlight it. Click on the magnifier icon on the left side of the field and choose “Insert Pattern” from the pop-out submenu.
From “Insert Pattern”, choose the Tab character at the very top of the list.
Leave the Replace field blank.
Choose “Replace All” and all the tabs will disappear from your file. You’ll see a nice, tidy vertical column of keywords and labels.
Synonyms
If you have any synonyms in your vocabulary, you’ll most likely want to convert them into ordinary keywords.
To do this, we’ll do two Find and Replace passes, one each to find and delete the left curly brackets and right curly brackets that set off synonyms in the list. Now our synonyms will be just regular old keywords.
And labels
If you have any labels in your file, you’ll want to delete them. Labels don’t output from the Structured Keywords dialog to the keywords field. They are just there to be, well, labels. It stands to reason that we don’t want them cluttering up our keywords vocabulary in other dialogs.
There probably aren’t too many labels in your file. The simple thing is probably to just delete them by hand. But Text Edit’s Insert Pattern function will zap them so slickly it seems a shame not to use it. Let’s give that a go.
We’re going to make a pattern that deletes the left bracket, then any string between our brackets, the right bracket, and then finally, the line break. (If we don’t zap the trailing line break, we’ll be left with some empty lines.)
Type the left bracket in the Find field.
Now choose “Any Characters” from Insert Pattern.
Type in the right bracket.
And go back to Insert Pattern and add the line break.
It is a common practice to use some sort of symbol, like a couple of stars or hashes, to indicate that a label is a label and won’t export to keywords. I use a tilde. This pattern will zap such symbols right along with the labels they rode in on.
Click “Replace All” and your labels will vanish from the file, which can now be imported into the Edit Keywords dialog.
You’re ready to go.
Our vocabulary is controlled
In this process, we’ve also synchronized our Structured Keywords and our Master Keywords List. Unfortunately, there is no ongoing synchronization function. Whenever we add a new keyword in one place, we’ll need to add it in the other.
We can, of course, do this Structured Keywords list to Master Keywords List transformation as often as we want. Once you’ve done it once or twice, it only takes a minute or two.
If we’re working on Windows, we can use Notepad instead of Text Edit. The procedure is more or less the same, except we don’t have that spiffy Insert Pattern feature. We’ll have to delete our labels the old-fashioned way (or use a third-party text editor). No worries, there usually aren’t that many labels.
In Notepad, we delete a tab by selecting and copying one in the text. (It looks like we’ve selected blank space.) Then, we paste the tab into the Find field, leaving the Replace field blank. It may take a few repetitions to get all the tabs.
And that’s all there is to it.
Can it really be that Text Edit doesn’t have a save-as command? How silly is that? Jump in the comments and let me know.
No save as option for Text Edit (and others). At least this means that I will not edit a file and forget to save as a different name (changing the original). The duplicate option works for me… after getting used to this different workflow.
I did make an Automator “Quick Action” to create the keyword list. I basically does what you describe.
1) open automator and create a new Quick Action for documents in finder.app
2) add the following sections
* Get contents of TextEdit Document
* Filter Paragraphs that do not begin with [
* Run Shell Script (/bin/zsch) pass input: to stdin
add this text: sed $’s/\t//g; s/\{//; s/\}//;’
* New Text File (plain text)
save as ‘Updated_Keywords.txt’ on desktop replacing existing files
3) Save this workflow as KWupdate.workflow
Then find your ExportKeywords_UTF8.txt file and open it in Textedit
Then select the quick action from finder (right click) and the updated keywords file will be created.
Filter removes the labels
The Shell script uses ‘sed’ to remove tabs and brackets.
The New Text File file name and location can be changed if needed.
Update: Add at the start of the workflow:
* Open Finder Items open with TextEdit
* Pause for 2 seconds
Then the exported keyword file is opened automatically
when selecting the ‘QuickAction’
an optional step could be added at the end:
* Quit Application Textedit.app
Hi Henry, I apologize. Your comments were languishing in my moderation queue. I just saw them today while I was there on a spam-cleaning mission. I have belatedly rescued them.