Batch merging videos: keep everything from A and just add an audio track from B

Hi everybody, thank You in advance for the support.

I have two MKV sets of the same videos (~100 files each, A is in english and B dubbed in other language), I would like to keep everything from version A (which has better picture quality) and just add an audio track from B for each file.

I can easily do it one by one through the GUI, but can You please help me finding a good batch script to automate the process?

Welcome!

I don’t think there’s something ready-made for this exact situation. Here’s a small bash script that might roughly do what you want. It makes several assumptions: source files are in different directories called A & B, but inside the directories the file pairs are named identically; the output goes into a directory called combined.

for a in A/*.mkv ; do
  b="B/${a%A/}"
  combined="combined/${A%*/}"

  mkvmerge --output "${combined}" \
    --no-audio "${A}" \
    --no-video --no-subtitles --no-chapters --no-global-tags --no-attachments "${B}"
done

I cannot help you with converting that into a Windows-type .bat for cmd.exe, though, nor into a PowerShell script.

You might also want to look into the available third-party batch processing tools.