Batch Convert AVI and MP4 files into MKV format

Convert AVI MP4 to MKV Continuing to get your movie collection in order you may find yourself wanting to change order encodes such as AVI or MP4 files into an MKV format. For instance, the easiest way to bypass the new Windows Media Foundation framework inside of Media Center is to use a non-native format such as MKV. Of course, this will also break support on Media Center Extenders as most often they will not support the MKV format.

Converting each movie from it’s current format to another using traditional means can be a task that many would give up before even starting. The idea of converting each file one by one can be daunting for those with large collections. That’s where these files and guide can come in handy. This will enable you to do a batch processing of AVI and MP4 files into MKV files.

Get the tools

Before we get started you will need a couple of items downloaded and installed. The first of which is MKVToolnix, this set of tools will provide the command line program used by the .bat file to convert any AVI or MP4 files which don’t include WMA audio. Install the program using the installer provided on the MKVToolnix website.

Second, this zip file, which includes a .bat file and a directory which should be placed in your movies directory. Also, these files are marked “Hidden” by default and necessity, you’ll need to enable hidden items which you can find instructions for here.

Getting Started

Once you have installed MKVToolnix and extracted the zip file to your movies directory you will need to move all your AVI and MP4 files to the main directory if they aren’t there already. The simplest way to accomplish this is to enter a search in Windows Explorer for .avi/.mp4 and cut/paste into the main directory.

Windows Explorer Search

This is done due to the fact that the .bat file doesn’t use recursive directory codes. There are four different versions of the batch file included in the zip.

  1. Just Convert – Will convert any AVI and MP4 files to MKV
  2. Convert and Move - Will convert to MKV then move to a directory with the same name as the file's name
  3. Convert and Delete - Wil convert to MKV then delete the original AVI/MP4 files
  4. Convert, Move and Delete - Will convert to MKV, move to folders then delete the originals

During conversion, if the file is able to be converted by MKVToolnix’s MKVMerge it will be. This is the fastest method of converting the files to the MKV format as it simply re-muxes the file into an MKV. If the original file uses WMA for audio, however, the conversion will not occur with current versions of MKVToolnix. Support for these files is planned for later versions.

Also, included is a version named simply “avitomkv.bat”. This version includes the ability to convert files encoded with WMA audio by using the HandbrakeCLI from This version is the most robust as it will re-encode all files, however, during this process the original files are deleted. This isn’t optional in this version and is irreversible, use with extreme care!

Stick with Hack7MC

Hopefully, this guide will get anyone looking to do a batch conversion of their media where they need to go. This little .bat file saved me much time recently converting a sizable collection of AVIs to MKV in order to circumvent Windows Media Foundation in Media Center.

Check out more Tips to Organizing Your Movie Collection on Hack7MC!


Reed Amanda said...

Thank you for these instructions, really helpful!! I'd also recommend Acethinker Video Converter which I have used for many years. It's a free web-based application to convert videos, you don't have to install anything.

Anonymous said...

Hello, Thank you very much for this is there a way to make it mux more than one audio track. The files I have are .avi they have 2 audio tracks the first russian the second english I just want audio track 2 to be muxed into the mkv container. Thank you for your time.

Leave a comment using any OpenID including Yahoo!, AIM, Google and more. You can even leave an Anonymous comment below!

Post a Comment

Hack7MC Has Moved!

Hack7MC has left Blogspot for a new home. Following the original address @ will take you to the new home page.