Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to remux all the files present in a directory into matroska container .mkv. with a script.

I'm new to mkvmerge!

edit: in mkverge gui this works well for me, loading just one file:

"mkvmerge" -o "/media/.../00062 (1).mkv"  "--forced-track" "0:no" "--forced-track" "1:no" "--forced-track" "2:no" "-a" "1" "-d" "0" "-s" "2" "-T" "--no-global-tags" "--no-chapters" "(" "/media/.../00062.MTS" ")" "--track-order" "0:0,0:1,0:2"

I haven't figured out yet how to get this into a bash script to run on all files in a directory.

these did not work

FOR %%A IN (*.MTS) DO mkvmerge -o "~nA.mkv" "%%~A"  


for file in *.MTS; do $file `mkvmerge -o $file.mkv`;done

Edit 2:
didn't work because of bad syntax! This DOES work!

for file in *.MTS; do `mkvmerge $file -o $file.mkv`;done
share|improve this question
What have you tried? Have you read the manpage? Please try something first and come back with a specific problem. – terdon Aug 18 '12 at 14:41
Thanks for the edit, removed my downvote. Well done for figuring it out, why don't you post your solution as an answer and accept it (just remove the backticks (`) around the command). – terdon Aug 18 '12 at 15:47
up vote 0 down vote accepted

This script works fine, something similar to an ffmpeg script I've used:

for file in *.MTS; do mkvmerge $file -o $file.mkv;done  

just have to call that something like and make executable, chmod +x

then I call it with a right-click Thunar custom action in the dir with MTS files, i.e. with custom action command /home/username/ %F and the Appearance condition *.MTS

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.