I have a Matroska file, having duplicate and/or empty streams inside.
Example:

For some reason, this example has tons of duplicate audio streams as well as empty subtitle streams.
After cleaning them up, it looks like this:

so the streams 3 to 13 were either a binary duplicate of stream 1 or 2, stream 18 was a binary duplicate of stream 17.
This process so far I was able to automate. (I just drag the mkv file onto a batch file currently)
Now knowing the IDs of the tracks I want to keep (or other way around, knowing those I want to delete), how could I automate it now, that the streams I do not want anymore are removed from the Matroska file itself?
What would be the best now would be a way, to give e.g. mkvmerge the input file and the IDs I want to keep and it muxes a new file, with all other data like language of the streams, chapters, attachments etc. but only those stream IDs I want to keep, thus making the file smaller.