Hi all,
I have more than 50 mkvs that I would like to mux with subtitles. It will take a lot of time if I have to do it one by one. I read somewhere that you can do this by creating a batch file. Unfortunately, I have no idea how to do it. I hope somebody can help me. Thank you.
+ Reply to Thread
Results 1 to 28 of 28
-
-
How are your video and subtitles files named? It will be easy if they are named same like video.mkv and video.srt.
-
-
Mkvmerge batch code:
Code:FOR %%f IN (*.mkv) DO ( mkvmerge -o c:\newfolder\%%~nf-new.mkv %%~nf.mkv %%~nf_track02.srt )
-
Do I need to change anything on your script or just copy paste & follow your instruction here
"Put the test.bat and mkvmerge.exe in same folder as your mkv files.
Create a new folder for you new mkv files, the c:\newfolder in this example. It should NOT be same as your current mkv/ssa files.
Run the test.bat. You can try with a few mkv/ssa files first."
To answer your question yes all of the subs (srt's) always have "_track02" at the end.
Question for you.
1. The script you provided will it also remove all the subtitles in the movie?
Basically what I would like to do is to remux all mkvs with the new subtitle (with "_track02") but remove all the original subs from the mkv.
2. Will it leave everything by default for the video,audio,chapters and tags?
Im totally noob at this I appreciate your help. -
Just copy everything and try with ONE mkv first.
I don't think it will remove any subs. I don't know how to do that easy using the batch batch.
You can also read https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg (how batch script works with ffmpeg but you use mkvmerge instead) -
Add -S (note the capital S) between the output file name and the source MKV name to remove the subtitles from the remux.
Code:FOR %%y IN (*.mkv) DO ( mkvmerge -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" "%%~dpny_track02.srt" )
Last edited by ndjamena; 5th Dec 2014 at 05:28.
-
-
[QUOTE=Baldrick;2360814]Mkvmerge batch code:
Code:FOR %%f IN (*.mkv) DO ( mkvmerge -o c:\newfolder\%%~nf-new.mkv %%~nf.mkv %%~nf_track02.srt )
I created a new folder put one mkv and sub. Then copy pasted the code above onto notepad save as *all files* name mux.bat. Also, I copy the mkvmerge icon into the same folder. When I click the .bat file cmd opens for a second then disappear.
Anything I did wrong? -
-
Then you're doing something wrong. What, if any, error messages are being thrown at you? (open a command prompt, CD /D to the directory, then type in the name of the .bat and the window will stay open once the bat has run).
-Edit- Oh, you need the actual MKVMerge.exe somewhere the batch can find it, not just a shortcut. The exe is in the Program Files directory (in windows) MKVToolNix, you can move the exe, add the full path name to the bat or add the full MKVTopolNix directory name to the PATH system variable. -
Last edited by newpball; 6th Dec 2014 at 00:55.
-
Update--- after hours of playing with the batch it finally work. I put the mkvmerge path instead of just "mkvmerge". The original subs were gone.yey. I also added "--language 0:eng" to set the language of sub to english based on what I read from here https://www.bunkus.org/videotools/mkvtoolnix/doc/mkvmerge.html
This is what I came up with.
Code:FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt" )
Does it look alright? Will it set all the settings for the video,audio,chapters and tags by default like the original mkv?I just dont want to start ripping dvd's again if I messed up
and is there anything I can add to get like a log in text file from the batch? -
Code:
FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt">"%%~dpny.log" )
-
-
Hi TeddyBear10 ,
> is there anything I can add to get like a log in text file from the batch?
YES .
Code:@echo on FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt">"%%~dpny.log" ) pause :end
!!! At the end , DON'T strike any key of the keyboard !!!
Right-click on that page => choose 'Select all' => Click on the 'ENTER' key .
Open a text editor => paste the clipboard .
Here , you have what you have selected .
The properties of the CMD file can be nodified , when a batch file is open ( for example ) .
Colors , number of lines , Height , width , etc.
Regards . -
Um, you probably should have copy/pasted an earlier batch, mine already outputs to a log.
Code:>"%%~dpny.log"
Code:FOR %%y IN (*.mkv) DO ( echo.>"%%~dpny.log" for /f "tokens=* delims=" %%g in ('"C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~ny-new.mkv" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt"') DO ( echo %%g echo %%g>>"%%~dpny.log" ) )
-
Hi ndjamena ,
Thanks for your's informations about log .
( I am a bit old , my mind is tired ) .
Regards . -
Code:
FOR %%y IN (*.mkv) DO ( echo.>"%%~dpny.log" for /f "tokens=* delims=" %%g in ('"C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~ny-new.mkv" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt"') DO ( echo %%g echo %%g>>"%%~dpny.log" ) )
Code:@echo on FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt">"%%~dpny.log" ) pause :end
-
you can always add a single log to one LOG that holds all of them, echo or type perhaps can return wrong thing while calling from within parentheses so maybe it is a good idea to just call function that always add single log that complete log:
Code:@echo on break>all_logs.log FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt">"%%~dpny.log" call :print_log "%%~dpny.log" del "%%~dpny.log" ) pause :end :print_log echo. >>all_logs.log echo %~n1.LOG >>all_logs.log echo --------------------------------- >>all_logs.log type "%~1">>all_logs.log goto :eof
Last edited by _Al_; 8th Dec 2014 at 10:17.
-
Hi TeddyBear10 ,
For example : you own 3 files .log in witch you have a text written .
--- Fichier_1.log
Fichier_1.mkv
--- Fichier_2.log
Fichier_2.mkv
--- Fichier_3.log
Fichier_3.mkv
If you create a batch file like below
@echo on
copy /b Fichier_1.log +Fichier_2.log +Fichier_3.log Groupement_1.log
rem OR
copy /b Fichier_*.log Groupement_2.log
pause
:fin
You'll get the same result for Groupement_1.log and Groupement_2.log
---
Fichier_1.mkvFichier_2.mkvFichier_3.mkv
---
Cheers .Last edited by aazerty; 8th Dec 2014 at 11:58.
-
Code:
@echo on break>all_logs.log FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt">"%%~dpny.log" call :print_log "%%~dpny.log" del "%%~dpny.log" ) pause :end :print_log echo. >>all_logs.log echo %~n1.LOG >>all_logs.log echo --------------------------------- >>all_logs.log type "%~1">>all_logs.log goto :eof
It works perfectly. Just one log for all the mkv's. Thank you everyone I really appreciate all your help. this will save me a lot of time! -
I hate to bring this old thread back but I just need help to modify the code below to use it for another two different batch process.
Basically, I would like to do the the following seperately
(1) remux mkvs without the original subtitles in it (just keep the video & audio file)
(2) remux mkvs with two new subtitles with name ending in "_track02" & "_track03". Track02 should be labeled forced & track03 is default track and should be next to audio in order of tracks.
Example:
Movie\Avatar.mkv (this has two subtitles in it)
\Avatar_track02.srt
\Avatar_track03.srt
Order of tracks after remux
Video
Audio
Track03 (default)
Track02 (forced)
Thank you for helping.
Code:@echo on break>all_logs.log FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" --language 0:eng "%%~dpny_track02.srt">"%%~dpny.log" call :print_log "%%~dpny.log" del "%%~dpny.log" ) pause :end :print_log echo. >>all_logs.log echo %~n1.LOG >>all_logs.log echo --------------------------------- >>all_logs.log type "%~1">>all_logs.log goto :eof
-
1.)
Code:@echo on break>all_logs.log FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy">"%%~dpny.log" call :print_log "%%~dpny.log" del "%%~dpny.log" ) pause :end :print_log echo. >>all_logs.log echo %~n1.LOG >>all_logs.log echo --------------------------------- >>all_logs.log type "%~1">>all_logs.log goto :eof
Code:@echo on break>all_logs.log FOR %%y IN (*.mkv) DO ( "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpyremuxed\%%~nxy" -S "%%~fy" --default-track 0:1 --forced-track 0:0 "%%~dpny_track03.srt" --default-track 0:0 --forced-track 0:1 "%%~dpny_track02.srt">"%%~dpny.log" call :print_log "%%~dpny.log" del "%%~dpny.log" ) pause :end :print_log echo. >>all_logs.log echo %~n1.LOG >>all_logs.log echo --------------------------------- >>all_logs.log type "%~1">>all_logs.log goto :eof
https://mkvtoolnix.download/doc/mkvmerge.html
Maybe MKVBatch will interest you as well.