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

**URL:** <https://help.mkvtoolnix.download/t/batch-merging-videos-keep-everything-from-a-and-just-add-an-audio-track-from-b/56>\
**Category:** Help\
**Created:** [July 4, 2023, 11:30pm UTC](https://help.mkvtoolnix.download/t/batch-merging-videos-keep-everything-from-a-and-just-add-an-audio-track-from-b/56 "2023-07-04T23:30:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleberro](https://help.mkvtoolnix.download/letter_avatar_proxy/v4/letter/a/e495f1/32.png) [@aleberro](https://help.mkvtoolnix.download/u/aleberro)\
**Post date:** [July 4, 2023, 11:30pm UTC](https://help.mkvtoolnix.download/t/batch-merging-videos-keep-everything-from-a-and-just-add-an-audio-track-from-b/56/1 "2023-07-04T23:30:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mbunkus](https://help.mkvtoolnix.download/user_avatar/help.mkvtoolnix.download/mbunkus/32/11_2.png) [@mbunkus](https://help.mkvtoolnix.download/u/mbunkus)\
**Post date:** [July 5, 2023, 7:25am UTC](https://help.mkvtoolnix.download/t/batch-merging-videos-keep-everything-from-a-and-just-add-an-audio-track-from-b/56/2 "2023-07-05T07:25:18Z")

</div>

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`.

```plaintext
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](https://mkvtoolnix.download/links.html).
