Here it is. I took the time to comment it well and rearrange some things.
It's in 2 files : https://pastebin.com/FQ7xqNSt https://pastebin.com/6S3qesWc
Keep the file names I chose when copy/pasting. Read the loop file to see how to use it quickly.
I forgot to say in the loop script’s quick explanations that you need mkvmerge and mkvpropedit from MKVToolNix (put it in the PATH variable if needed) and nodejs to make that script work.