Reading Titles from MKV

I have a script I wrote in bash to change the title that pops up in VLC at the start of a video which we use in our video issue process.
mkvpropedit "file.mkv" --set title='Title Whatever'
I works great but someone else has been creating the files and storing them as well and I’ve just discovered that he has not been setting the titles as per process for a very long time. Where I recorded ‘Input File Title’ here he literally put that text in. We have thousands of files in hundreds of directories and I wanted to know which files to target for changes. I could easily change them all but then the version management system would go bonkers and issue every file on the next release totalling several Tb which will be an issue for everyone.

I’ve tried but I can’t get mkvinfo or mkvextract to pull the information into a variable. If there a CLI option that I can put in bash so I can check the settings in the title. I have used
mkvinfo file.mkv
To extract everything and it is there in

|+ Segment information
| + Timestamp scale: 1000000
| + Title: Input File Title

I could extract it from there if I have to but there must be an easier way; for example something that looks like;
var=mkvextra "file.mkv" title
Is this possible? Any help will save me a lot of time.

Welcome!

Use mkvmerge’s JSON identification mode. The output is what mkvmerge finds in that file encoded in JSON, which you can easily process further with a scripting language or other command-line tools such as jq. For example:

mkvmerge -J "your file.mkv" | jq -r .container.properties.title

will only output the title or none if there’s no title.