How to use MKVToolNix to extract SRT subtitle form MKV file

Here is a quick way to extract all subtitle tracks from every mkv file in the current directory.
Just save the below code as .BAT or .CMD file format.

@ECHO OFF
ECHO Extracting all .mkv subtitle tracks in current folder.
ECHO.
ECHO.
FOR %%A IN (*.mkv) DO (
FOR /F %%I IN ('mkvmerge --identify "%%A" ^| FIND /C "Track ID"') DO (
IF %%I GTR 0 (
ECHO Analyzing "%%~nxA"
FOR /L %%T IN (0,1,%%I) DO (
mkvmerge.exe --identify "%%~dpnxA" | FIND /C "Track ID %%T: subtitles">NUL
IF NOT ERRORLEVEL 1 mkvextract.exe tracks "%%~dpnxA" %%T:"%%~dpnA-ID%%T".srt
)
)
ECHO.
ECHO.
))
ECHO.
ECHO.
ECHO The end.....
PAUSE

This batch file will require the files mkvmerge.exe and mkvextract.exe. Both come with MKVToolNix

NOTE: This will extract all ass/ssa, srt, sup, idx/sub, (and maybe more) subtitles and save them as MKVfileName-IDx. Where x is the MKV TrackID.
ONE CAVEAT THOUGH… All but idx/sub end up with the file extension .SRT. You will have to rename that extension if you need the extension to be true for the format. An example of this is SubtitleEdit, where it will not import “.SUP” sub-pictured subtitles if the extension is .SRT.

3 Likes