Controlled Vocabulary

Add hierarchical keywords to your images using the Controlled Vocabulary Keyword Catalog!

Variables Overview
Compile, Copy, or Create Token
Apply Token


Using Photo Mechanic’s Variables to Generate New Metadata Values.

There are times when you may need to modify the metadata values within a field, or generate new values based on the value in another field. As one example, let's say you need to have the value of a metadata field shortened, in order to compensate for a search operation that will be done in an online service. I had a question from an event photographer who had seen the Filename 2 Title page, and wanted to know if it was possible to do something similar, but only use part of the filename. On that page, I'd outlined various ways to automate the writing of the filename into the Title (Object Name) field in order to preserve that information in case someone changes the file name after download the file to their hard drive.

In his case, he was using a particular web-based photo service and wanted to make it easy for clients to see their images. This service allows you to search for a filename, but you have to put in the full file name, not just a portion. This event photographer uses a system where he hands out business codes with a barcode/number on them.

This is used to group all photos taken at a particular event, and if different barcodes are used at a single event, then the segments of that event can be differentiate. The event software uses the barcode as the first part of the filename, followed by a sequence number (a six digit barcode followed by an underscore and then a sequence number.... like 01400_001.jpg). In this particular case, the photographer wants their clients to be able to type in that six digit barcode number, and find all the images in which they appear (rather than typing in the full filename and only finding that one image). However, the photographer doesn't want to have to go through each image to add those codes, so he was looking for a way to automate this process.

Using the Variables feature in Photo Mechanic it is possible to extract a portion of another metadata value, such as a filename. In this article, I will show you how you can use the Variables feature; which can be used to pull information from pre-existing locations, such as that stored in the Exif information (capture date, f-stop, shutter speed, etc.), as well as any other metadata fields that have previously been entered. In this particular instance, we will expand upon what is possible with a simple Filename 2 Title automation, by extracting a substring with some additional code.

Photo Mechanic's Variables Overview

While this Code Replacement feature can be very useful when rapidly writing captions, it becomes even more powerful when used in tandem with the Variables feature. Let’s look at how we can use these two features together to automate the insertion of keywords.

If you send your keywording to an outside vendor, what you will typically receive is a CSV (Comma Separated Value) or tab-delimited text file containing file names and corresponding keywords. The following method will outline how to easily move those keywords in the text file into the Keyword field of your images without any repetitive cut-and-paste operations.

Create the Variable Token
One of the options I'd mentioned in the Filename to Title page shows how you can use Photo Mechanic's Variable feature to do part of this. Using the token {filenamebase} will insert the filename minus the extension into which ever field you want. It turns out that there are other ways to further modify the output, according to Camera Bits CEO, Dennis Walker. He was kind enough to point me to a page on their Wiki that covers the use of the "Variable Substring Extraction" in detail.

Apply the Token

In this case it's only a four step process:

  1. Select the images in the active folder which you want to modify
  2. Open the IPTC Stationary Pad (Control + I) in Photo Mechanic
  3. Type one of the following "variables" noted below into the "Title/Object Name field:
  4. Press the "Apply Stationary to Selected" button, and that value will be calculated from the filename and written into that field for each image.

{fbas:0,6} short version, or longer version {filenamebase:0,6}

The first part of this variable command says to use the value of the filename, but without the extension, the colon tells it there is more work to be done, and that you want to extract six characters starting at the home position (zero) of the file name.

If you'd only wanted to pull the number sequence, minus the underscore, you could use {fbas:-3} which pulls the three characters to the left of the period before the file extension.

Using {fbas:0,6} as token will extract 01400 from 01400_001.jpg

Using {fbas:-3} as token will extract 001 from 01400_001.jpg
Conversely, if instead, you'd only wanted to pull the number fsequence, minus the underscore, you could use {fbas:-3} which pulls the three characters to the left of the period before the file extension.

Camera Bits Forums:

Camera Bits / Photo Mechanic Wiki on Substring Extraction of Variables


examples  |  books  |  products  |  image databases  |  links  |  what's new
imagedatabases  |  programs  |  IPTC standard  |  downsampling  | filenaming 
metalogging  |  captioning  |  keywording  |  guidelines  | metalog resources
home  |  contact  | sitemap