Author Topic: Rookie code replacement question  (Read 550 times)

Offline bazography

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Rookie code replacement question
« on: May 18, 2023, 01:19:28 PM »
I have never used code replacements before but I have now figured out how to use them to tweak some camera metadata, which I’m writing to an unused field when I ingest images.

Rookie question...
Is it possible to tell PM to only use code replacements when I import from a specific camera (in this case model = OM-1) and ignore code replacements otherwise?

I realize I could create a snapshot of my ingest settings specifically for that camera, but normally my ingest setting never change, so the chances of me remembering to switch back and forth after all these years are decreasing with every gray hair. So if there is an automated way of doing it that would be ideal.

Offline Mick O (Camera Bits)

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 525
    • View Profile
    • Camera Bits
Re: Rookie code replacement question
« Reply #1 on: May 18, 2023, 02:42:45 PM »
Hi bazography,

One way you could approach this is to make Your codes have "OM-1" in them and them and then insert the {model} variable into the full code replacement string. 

Example code replacement line:

Code: [Select]
OM-1_foo New text

Then  use this in a PM field:

Code: [Select]
={model}_foo=

For any files from the OM-1, that will replace to "New text" and for other cameras, the "default replacement" would be inserted. You could set this up with all the models you use for different replacements based on the camera model.

Depending on the situation, though, it might be cleaner to use Hot Codes, which allow for empty default replacements so that for non-OM-1 cameras, nothing would be inserted

The Code Replacement file for that might look something like this (I will attach the .tsv, too):

Code: [Select]
// Code Replacement file with Hot Codes for Photo Mechanic
//== {model}
//## foo
OM-1 New text
//??

If you use [foo] in any metadata field (note the square brackets for hot codes,) then on all files from an OM-1, "New text" would get inserted and for all other cameras, nothing would get inserted. The line that starts //?? is where you would put default replacements. Not putting anything there means that when PM encounters [foo] from a model other than OM-1 it will not insert anything

Hopefully, you can start playing around with these ideas and adapt them to fit your desired outcomes :-)

-Mick

More documentation:

Deep dive into Hot Codes:
https://docs.camerabits.com/support/solutions/articles/48000358684-hot-codes

Video webinar about Hot Codes:
https://www.youtube.com/watch?v=v_y7agK6X_8
Mick O
Camera Bits

Offline bazography

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: Rookie code replacement question
« Reply #2 on: May 18, 2023, 10:29:15 PM »
I really appreciate the help Mick, but I only started looking at code replacements a few days ago and this is a bit too far over my head. The hot code method you suggested sounds like the best route, and I kinda-sorta get the idea, but am not sure exactly where all these commands get placed.

I’ve been playing with a few different replacements, but lets use {lens35} as an example. Lets say my code replacement text file contains the following:

8    16
9    18
10    20
12    24

Where do the above focal lenghts be inserted into the hot code example you gave me?

And then in the IPTC field I have this entered: Focal Length Equivalent:  ={lens35}=mm
Again I’m unsure where [foo] gets added.

I think if I saw an example of what the complete code looked like I would be able to grasp it. Thanks again.

Offline Mick O (Camera Bits)

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 525
    • View Profile
    • Camera Bits
Re: Rookie code replacement question
« Reply #3 on: May 19, 2023, 10:26:58 AM »
Now that I have a better idea of what you're trying to do with lens equivalences, I can offer this workaround which is a big ol' kludge using MS Excel or Google Sheets:

http://forums.camerabits.com/index.php?topic=9492.msg47521#msg47521

(Note that example is from back when the default code replacement delimiter was \, so you'd want to change
Code: [Select]
\lens35-{lens}\  to
Code: [Select]
=lens35-{lens}=

I can't immediately think of a way to do this so that it would ignore any files not taken on a crop-factor body, so my recommendation would be to save whatever metadata template you're working with as a snapshot preset and only apply it selectively to your OM-1 files.

Mick
Mick O
Camera Bits

Offline bazography

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: Rookie code replacement question
« Reply #4 on: May 19, 2023, 08:42:38 PM »
Thanks again Mick. All good info as I learn about code replacements. I will take your recommendation though and just create a snapshot for the OM-1 ingest. Now I just have to re-train the ol' brain to remember to switch!
Cheers.