0

To add subtitles to a single file I use the following command:

mkvmerge.exe -o g:\movie01.mkv --default-track 0 --language 0:pl movie01.mkv movie01.srt

Where:

movie01.mkv is the name of a video file

movie01.srt is the name of a subtitle file (it is always the same as the video file)

g:\movie01.mkv is the output file

How do I run the above-mentioned command for every file in a directory?

0

This command will loop through all mkv files and run the command for each of them (I suggest putting it in a .bat file). The command should be run in the directory that contains your mkv-files.

for %%A in (*.mkv) do if /i "%%~XA"==".mkv" ( 
    c:\<path to mkvmerge>\mkvmerge.exe -o g:\"%%A" --default-track 0 --language 0:pl "%%A" "%%~nA.srt"
)

%%A is equal to the exact filename.

%%~nA is equal to the filename without filetype.

3
  • mkvtoonix gives me an error: Error: No source files were given. – menteith Jan 15 '17 at 9:43
  • Are you running the command in the directory with your mkv files? (try placing the .bat file in that dir and run it. – Nichlas H. Jan 15 '17 at 9:49
  • Yes, I am. The problem was "". When deleted everything is working. – menteith Jan 15 '17 at 10:03
0

Provided all files have the .mkv extension, how about this:

for /r %%video in (*.mkv) do mkvmerge.exe -o %%video --default-track 0 --language 0:pl %%video.srt

%%videois the variable which identifies each files in the current folder with the specified extension. After do I run the command on each file, and I use the same variable to call the srt file.

1
  • mkvtoonix gives me an error: Error: No source files were given. – menteith Jan 15 '17 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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