Author Topic: Automatic adding keywords based on catalog info  (Read 4099 times)

Offline LRAT

  • Member
  • **
  • Posts: 67
    • View Profile
Automatic adding keywords based on catalog info
« on: June 17, 2024, 10:50:05 PM »
I spent a lot of time sorting about 40,000 pictures in the catalog databases. To avoid doubling up on the workload, I'm hoping there might be a script that can extract catalog breadcrumb and insert it as keywords in the pictures.

Let me explain:
For example, I have 13 pictures in a catalog with the following breadcrumb trail: "Where - Africa - Hurghada - Sha'ab Abu Nuhas". I would like to apply a script that would add/append "Where, Africa, Hurghada, Sha'ab Abu Nuhas, " to the Keyword field of these 13 pictures. The last extra comma and space is deliberately to anticipate adding more keywords later on.

The script should be able to run on every catalog and sub-categories to extract the data automatically.

Is that possible? If yes, it would save me hours or even days of work.

« Last Edit: June 20, 2024, 03:21:15 PM by LRAT »

Offline Mick O (Camera Bits)

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 553
    • View Profile
    • Camera Bits
Re: Automatic keywording from catalog info
« Reply #1 on: June 18, 2024, 09:49:25 AM »
Hello LRAT,

When you say "breadcrumb trail" do you mean that is the folder structure where the images are located? (example:  /Where/Africa/Hurghada/Sha'ab Abu Nuhas) If so, you could experiment with putting something like this into the keywords field:

Code: [Select]
{folderpath:1:tr:\//,}
This will insert the folder path, except the leading / and then translate the rest of the / into commas.  Try it on a few samples and see if that is what you are expecting.

More info on how this variable substring extraction works:
https://docs.camerabits.com/support/solutions/articles/48001077381-variable-substring-extraction

Mick
Mick O
Camera Bits

Offline LRAT

  • Member
  • **
  • Posts: 67
    • View Profile
Re: Automatic keywording from catalog info
« Reply #2 on: June 18, 2024, 02:08:45 PM »
That sounds great! Currently, I'm away from home but will try this at the earliest opportunity.
Thanks for your help! Much appreciated.

Offline LRAT

  • Member
  • **
  • Posts: 67
    • View Profile
Re: Automatic keywording from catalog info
« Reply #3 on: June 20, 2024, 03:10:32 PM »
Hi Mick O,

I hope you're doing well.

I was able to check it out and it worked. However, it didn't provide the desired outcome as it showed the location of the picture on the computer. What I'm after is the information of the catalogs. I have several catalogs (e.g., When, Where, etc.), and each catalog has subcategories.

Using the previous example, I have a catalog named "Where." In this catalog, there's a sub-category "Continent" (in this case "Africa"), then it drills down to "Country" (in this case "Egypt"), and so on.

So, what I would like to see in the keyword section is basically: "Where," "Continent," "Country," etc. (That is the breadcrumb trail in the Catalogs and not the location of the file on my PC).

Is that possible?

Thanks for your help!

Best regards,

Luke

Offline ahoward

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 973
    • View Profile
Re: Automatic adding keywords based on catalog info
« Reply #4 on: June 20, 2024, 03:41:45 PM »
As we have no concept of "sub-categories" in Photo Mechanic Plus, can you clarify what you mean by "sub-category"? Are you referring to the Collections feature and you've built sub-collections with the hierarchy you're describing?

Offline LRAT

  • Member
  • **
  • Posts: 67
    • View Profile
Re: Automatic adding keywords based on catalog info
« Reply #5 on: June 21, 2024, 03:11:54 PM »
It seems it's harder to explain what I mean than what I thought.
Attached is a screenshot.
So you see that I drill down from Continent to the country, then the area/Town and then to the spot itself.
Thanks.

Offline ahoward

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 973
    • View Profile
Re: Automatic adding keywords based on catalog info
« Reply #6 on: June 21, 2024, 03:16:59 PM »
So these are Collections, right?

Offline LRAT

  • Member
  • **
  • Posts: 67
    • View Profile
Re: Automatic adding keywords based on catalog info
« Reply #7 on: June 21, 2024, 03:32:17 PM »
Yes, my apologies for using the incorrect terms.

Offline ahoward

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 973
    • View Profile
Re: Automatic adding keywords based on catalog info
« Reply #8 on: June 21, 2024, 04:29:30 PM »
Okay, thank you.

So, there are no variables that return which collection your images are in, and due to the fact that an image can be in multiple collections and sub collections, it would be tough to make variables that work for everyone. For example, lets say I have A catalog with a collection called Parent with two sub collections: child1 and child2:

Image1 is in both child1 and child2

If we have a variable that returned the collections, should it just return "Child1, Child2"? Or "Parent >Child1, Parent>Child2"? Or "Parent>Child1, Child2"? I'm sure there are more things that would technically make sense but may or may not be what you want.

If I can suggest modifying your workflow, I think you'd be able to accomplish what you are trying to do without ever having to do the task of manually adding items to various collections by using Photo Mechanic Plus's Filters

For example, there are metadata fields specifically for the location where the image was created. If you populate these fields, you can then use Filters to get only the images from a specific location.

Of course, not every location name is unique. I'm in Portland, Oregon, but what if I have images from Portland, Maine? Filters take care of that. Filters act from the top down. If I choose something in the top filter, the number of items available in the lower filter gets adjusted. If you take a look at my attached screenshots, you'll see what happens when I have set up a Locations Shown > State and then City filter. If I don't click on a state, I see all of cities in my catalog, but once I do click on the state, I only see the cities of the images where images have that state in their metadata. If you happen to have a device that puts the GPS coordinates into your images (or you add them later in Photo Mechanic), you don't even really need to enter the location information, reverse geocoding can do that for you. And obviously you'd not want to have to set these filters up each time, so using the Snapshot function (the little flashbulb button at the top of the filters) lets you save a filter with a name, so once you set up your filters, save a snapshot to be able to pull up that set of filters again later.

I'm not sure what's in your other collections, as you've only really discussed location information so far, but I assume "When" has to do with Date and Time, which you can Browse or Filter by, and you'd be able to set up an appropriate set of filters for the collections have under the Event collection. I'm assuming "All" is just a collection of all items in all catalogs? You can pull up a contact sheet with every item in all catalogs by doing a Catalog Search for the period character (.)

I understand that this is a departure from your current workflow, but I hope you are able to employ some of these suggestions in your use of Photo Mechanic Plus

Offline ahoward

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 973
    • View Profile
Re: Automatic adding keywords based on catalog info
« Reply #9 on: June 21, 2024, 04:38:09 PM »
I forgot to add that once you have your location information set up correctly, you'd then use the appropriate variables to put that information where you want.

Offline LRAT

  • Member
  • **
  • Posts: 67
    • View Profile
Re: Automatic adding keywords based on catalog info
« Reply #10 on: June 21, 2024, 05:06:00 PM »
Thanks, ahoward!

Yes, that seems to be a different strategy, and I will take it onboard. However, adapting this strategy means I will need to manually add all the different locations to the pictures in the collections. That will be a lot of work, and the data still won't appear in the keywords unless I load the variables into the keyword sections.

I was hoping I could extract the data from the breadcrumb trail in the Catalogs/Collections, but from what I've read, that seems to be impossible. Anyway, it's food for thought, and I really appreciate your input, showing an alternative to my thinking process. Thanks!

Oh by the way, yes, I have multiple catalogs: All, Events, When, Where, Who, Work
All = Every picture in my collection (38,458)
Events = Sorted by activities such as scubadiving, wildlife, etc.
When: The year the picture was taken. This makes it easy to find pictures per year
Where: The geographical location: Continent, Country, Council/Shire/Province/County, City, Post code, Adress, Sublocation/Venue, Organization/Company
Who = The people appearing in the pictures
Work = Everything work related

Attached is the Metadata (IPTC) Info template I use