# 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:** 1\
**Showing post:** 2

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

---

_[View the full topic](https://help.mkvtoolnix.download/t/batch-merging-videos-keep-everything-from-a-and-just-add-an-audio-track-from-b/56)._
