Author Topic: How to Transfer part of the filename into the metadata and append new info?  (Read 1527 times)

Offline Sonadiatoms

  • Newcomer
  • *
  • Posts: 17
    • View Profile
I have 100-character file names with a string of important ID info at the end.  I want to extract this ID number and embed it into the metadata of the image.

Here is an example of one of these files:
Zirnworks_persian_bright_sunlight_worlds_fair_city_moth_green_y_3a23f4c9-6c37-4e22-b0a0-b80947cb122f.png

I want to extract that last 36 characters of the filename:
3a23f4c9-6c37-4e22-b0a0-b80947cb122f

And embed it into the "Job ID" field of the metadata.

Then, for the "Source" field, I want to append a string at the beginning, such as a web url:  www.website.com/3a23f4c9-6c37-4e22-b0a0-b80947cb122f

Is this possible?  If I can get it working I will buy PM+ for sure.  Thanks!
« Last Edit: November 27, 2022, 10:42:51 AM by Sonadiatoms »

Offline Mick O (Camera Bits)

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 527
    • View Profile
    • Camera Bits
In the Variables feature in Photo Mechanic, this is something called substring extraction that can do what you want. 

The documentation on that is here:
https://docs.camerabits.com/support/solutions/articles/48001077381-variable-substring-extraction

If you put {filenamebase:-36,36} into the Job ID field, does it show what you need?
This will always extract the last 36 characters from the filename base (i.e. not including the extension)

Then, you could put this into the Source field: www.website.com/{filenamebase:-36,36}

Remember that you can try this out in the Metadata (IPTC) Info window on a single file and then hold down the Modifier key (Option key on Mac, Shift key on Windows) and you will see the "OK" button in the lower right change to "EVAL" which will show you what the variable will expand to. If you see that you made a mistake, you can then click "Cancel" to try again without applying the changes.  When you are confident that you have the right process, you can use the Metadata (IPTC) Template to make this adjustment to batches of selected files.

Give it a try and let us know if you have any other questions

Mick 



https://docs.camerabits.com/support/solutions/articles/48001131428-the-modifier-key
Mick O
Camera Bits

Offline Sonadiatoms

  • Newcomer
  • *
  • Posts: 17
    • View Profile
Hello Mick, thank you for the fast reply and additional resource info.  This did indeed work.  It appears that running this operation on all my photos actually embeds the data into the file itself (which is what I want, in this case).  I was wondering if it the variables might update in real time, such that they change if the file name changes.

I have just purchased PM 6+.  Thanks!

Offline ahoward

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 804
    • View Profile
No, it is not possible to do any sort of live updating of metadata. Apply the Metadata Template after changing the name to make sure that the field that contains the updated filename.

Offline Mick O (Camera Bits)

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 527
    • View Profile
    • Camera Bits
Here is some info about using the Snapshot icon to save your choices in the Metadata (IPTC) Template as a preset:

https://docs.camerabits.com/support/solutions/articles/48001142336-snapshots

-Mick
Mick O
Camera Bits