This is a fantastic batch that works great for me. But I would actually need it to work with subfolders AND erase original video and sub files on completion. I would like it to work on hundreds of my files and I don't have enough space on my HD to keep the old files and the new ones. I don't know anything about coding batch files, could somebody help ?I've created a Windows Batch (.bat) file to solve a similar scenario, and I hope others find useful.
PasteBin: http://pastebin.com/Xqu2ZA7m
Code:@ECHO OFF REM // ======================= REM || Batch Subtitle Muxing REM || for MKVmerge REM || v0.4-20150511 by drudge REM \\ ======================= REM @@ This batch script will scan the provided directory (or current folder) REM @@ for video files, attempt to match them with subtitle files, REM @@ and mux them using the MKVmerge command line. REM // ---- ---- ---- ---- REM || USER CONFIGURATION REM // full path to mkvmerge.exe SET "muxpath=C:\Program Files\MKVToolNix\mkvmerge.exe" REM \\ -- -- -- -- -- REM // full path to unrar program, make sure to include switches SET "rarpath=C:\Program Files\7-Zip\7z.exe" SET "rarcmd=e" REM \\ -- -- -- -- -- REM // output path (with trailing slash) REM ++ leave blank for working directory SET "outputdir=" REM @@ default: SET "outputdir=" REM \\ -- -- -- -- -- REM // prepend text to output filename REM ++ REQUIRED if outputdir is left blank SET "fileprefix=subtitled-" REM @@ blank: SET "fileprefix=" REM \\ -- -- -- -- -- REM || END USER CONFIG REM \\ ---- ---- ---- ---- REM -- editing below this line should be done precisely. (here thar be dragons) REM =========================================================================== REM @@ simple counters SET /A "mc=0" SET /A "me=0" REM @@ default working path SET "wp=." REM @@ optional working path via argument IF EXIST "%~1" SET "wp=%~1" REM @@ ready steady go! CLS ECHO =========================================================================== REM @@ attempt to use custom setting for output path IF EXIST "%outputdir%" ( REM @@ user has provided output path ECHO == User Setting -- Output to: [%outputdir%] ) ELSE ( REM @@ no custom setting, check for prefix IF [%fileprefix%]==[] ( ECHO @@ ERROR: empty [fileprefix] setting requires [outputdir] to be set SET /A me+=1 GOTO:done ) REM @@ use working path for output SET "outputdir=%wp%\" ) FOR %%H IN ("%wp%") DO ( REM @@ because "." doesn't tell us where we are ECHO == Scanning [%%~dpfH\] for video files... ) :getfiles FOR %%I IN ("%wp%\*.avi", REM "%wp%\*.customVideoExtension", "%wp%\*.mkv", "%wp%\*.mp4") DO ( REM @@ found a video file, now check for subtitles CALL:getsubs "%%~I" ) GOTO:done :getsubs FOR %%J IN ("%wp%\%~n1.idx", REM "%wp%\%~n1.customSubtitleExtension", "%wp%\%~n1.srt") DO ( REM @@ check for paired subtitle files. USF/XML may require this check as well IF %%~xJ==.idx IF EXIST "%wp%\%%~nJ.idx" IF NOT EXIST "%wp%\%%~nJ.sub" ( IF EXIST "%wp%\%%~nJ.rar" ( ECHO -- [%%~nJ.sub] -- Found potential .rar ECHO | SET /p extdone=">> " "%rarpath%" "%rarcmd%" "%%~dpJ%%~nJ.rar" | FIND "Extracting" ) ELSE ( ECHO @@ ERROR: [%%~nJ.idx] -- Missing .sub file SET /A me+=1 GOTO:eof ) ) REM @@ subtitle found, time to put it all together IF EXIST "%wp%\%%~nJ%%~xJ" CALL:muxit "%%~f1" "%%~xJ" ) GOTO:eof :muxit REM @@ make sure the destination file doesn't exist first IF EXIST "%outputdir%%fileprefix%%~n1%~x1" ( ECHO @@ ERROR: [%~n1%~x1] -- Existing output file SET /A me+=1 GOTO:eof ) REM @@ we've made it! SET /A mc+=1 REM @@ now we let mkvmerge work its magic ECHO | SET /p muxdone="++ Muxing: (%mc%) [%~n1%~x1]" "%muxpath%" -q -o "%outputdir%%fileprefix%%~n1%~x1" "%~1" "%wp%\%~n1%~2" ECHO ..complete REM @@ success! GOTO:eof :done ECHO == Finished Processing: %mc% completed / %me% errors ECHO =========================================================================== REM @@ game over, man pause
+ Reply to Thread
Results 31 to 39 of 39
Thread
-
This is a fantastic batch that works great for me. But I would actually need it to work with subfolders AND erase original video and sub files on completion. I would like it to work on hundreds of my files and I don't have enough space on my HD to keep the old files and the new ones. I don't know anything about coding batch files, could somebody help ?
-
-
I'm pretty lost with the codes here especially since I dont have much experience with bat files or bat coding.
But can any1 help me with doing a batch mux? basically I just want to disable subtitles for all of the video files in my 1 folder. The output must be outside the folder (the previous folder) and it must not delete the original file just to be safe.
Would also appreciate it if you can include a way to reverse the default audio order for the 2nd audio to be the main while the 1st to not be the default audio. Or for the japanese instead of english and vice versa (incase I need this knowledge in the future). -
-
if you want I wrote this C# GUI..
https://github.com/Bazzu85/MKVmergeBatcher
try 1.167 version (windows only) -
I know this is an old thread, but it popped up in search and it did not have the solution for me.
I found this thread when I needed to mux too many files, HEVC video in mkv container (without audio) and opus in plain audio files. I am new to scripting, thus my script is simple. Please note, subdirectory 'done' is not created automatically, it must exist before executing. You could add 'mkdir -p done' to the script if you wish. Files were named like this:
Code:foo0.mkv foo0.opus foo1.mkv foo1.opus ...
Code:find -type f -exec basename -s .opus {} \; | { while read filename ; do mkvmerge -o done/"${filename%}.mkv" "$filename.opus" "$filename.mkv" done }
-
Hi drudge. Is it possible to modify your script that accepts MP4 and SRT files...but output MKV instead? Unfortunately I don't have the coding dexterity to do this.
Downloading MP4 files with SRT is quite common, but since the audio may not be MP4 compliant, MKV is best. Thanks!