Metadata Mechanic - First Letter Uppercase failing after pipe

Started by Redinstead, October 15, 2025, 04:58:01 AM

Previous topic - Next topic

Redinstead

There seems to be a bug in the First Letter Uppercase (Capitalize) functionality of Metadata Mechanic. I have run it on a couple of test files to first go lowercase and then to Capitalize the first letter.

I get results such as this:

Landmarks|the Scalpel
Tours And Trips|london June 2022

It seems that it's ignoring the very first letter after the pipe and then waiting for the next word to then capitalize it. I'm assuming this is because it's seeing the words immediately after the pipe as a "run-on"? So it's interpreting Trips|london all as one word rather than starting fresh post pipe, although I don't know what's happening in the background.

If I'm correct this would explain why going all lowercase or uppercase isn't affected.

Mario

Mhm...

The MDM uses a regular expression to detect word boundaries and then transforms the first character following the boundary (if any) to upper case. You example shows two rows and looks like hierarchical keywords? You did not mention the source of the data.

I guess the would need to expand the regular expression to also support | as the beginning of a word boundary...

Try this:

1. Make a backup copy of the file  "C:\ProgramData\photools.com\IMatch6\webroot\imatch\apps\md-mechanic\src\app.js"

2. Then open the file in Windows Notepad or a good editor like Visual Studio Code.

3. Go to line 837 where it reads: case 'capitalize':

3. Change the line starting with newVal = to

newVal = newVal.replace(/(^|[\s|])(\w)/g, (_, boundary, firstChar) => boundary + firstChar.toUpperCase());
It should look like this afterwards:

You cannot view this attachment.

Save the file and close and reopen the Metadata Mechanic.
Give it a try and let me know it it worked.

Redinstead

Ah yes, sorry. I should have said it was hierarchical keywords.

That has done the trick, although I had to do a PC reboot for it to kick in. It must have been sitting in the cache or something, perhaps. 

In any event it looks to be all working with that modification - thank you!

Redinstead

Actually, I spoke too soon. It fixes from lower case to Capitalize but if all already capitalized then it doesn't make the rest lower case. I can see what I need to do from the original line 837 though - the replacement is just missing the lower case portion. Running to work but I'll do that later today and I'm sure it will be fine.

Mario

Quoteif all already capitalized then it doesn't make the rest lower case.
This is not part of the plan.
It just makes the first letter uppercase. If the entire word is already in upper case, this mode does not change anything. It only modifies the first letter and leaves the rest of the word alone.
Users might be surprised when words include capital letters somewhere in the sentence are touched.

You would probably first have to run a "to lower case" and then a second pass to "first letter uppercase". Simple enough.

Redinstead

Ah - good to know that's intentional. Yes indeed - very easy to do that if needed. Thanks

Mario

I've added a new "Lowercase, first letter upppercase" mode for the next release.
This combines the two runs into one. For the time being, use two runs to produce the outcome you need.