Thanks, Karan, this was very useful to me, too. I've modified your script so that you can now pick a language (specified by 3LC (eng, ned, swe etc.)) for the subtitles you would like to keep. Also, I removed the part where the input files get deleted and chose to add a suffix to the output file.
Here's my version:
:: remux all mkvs under a certain subfolder with all subitles
:: but those as specified by %language% parameter removed.
@echo off
setlocal enabledelayedexpansion
:: set your variables here
set rootfolder="C:\temp\New folder"
set language=eng
set suffix= (eng sub)
:: do the remuxing
echo Remuxing all mkvs in %rootfolder% and its subfolders.
for /r %rootfolder% %%a in (*.mkv) do (
set subs=
set mkv=%%a
for /f "tokens=3 delims=: " %%b in ('mkvmerge -I "%%a" ^| findstr /i /r ".*subtitles.*language:%language%.*"') do (
set subs=!subs!,%%b
)
for /f "tokens=*delims=," %%c in ("!subs!") do (
set subs=%%c
)
if not exist "%%~dpna%suffix%%%~xa" if not "!subs!"=="" (
mkvmerge -q -o "%%~dpna%suffix%%%~xa" -s !subs! "%%a"
if errorlevel 1 (
echo Warnings/errors generated during remuxing of "%%a".
) else (
echo Successfully remuxed to "%%~dpna (eng subs)%%~xa".
)
) else (
echo Input file "%%a" has no subtitles in %language% or output file "%%~dpna%suffix%%%~xa" already exists. Skipping this file.
)
)
pause
1Which part is not working, what are the errors you get? Did you first test the for...do part, just echoing %%A? Did you then try one single DO... on one of the names coming out of the first test? – Jan Doggen – 2013-05-24T10:17:13.473
That was just an example from the internet. I have know idea what I'm doing. This is the last part to setting up my automated media center for all the legal videos that I purchase. I'm now trying to teach myself this code stuff, so I can write this batch file. – David Custer – 2013-05-24T10:36:56.783
1Then learn yourself "batch programming" or "batch file programming" (these are your search terms, together with maybe "tutorial") and split your effort into the two steps I suggested. – Jan Doggen – 2013-05-24T10:44:22.893
I got this do mkvmerge -o ./newfiles/
basename "$i" mkv
.mkv --no-subtitles "$i" ; done ....but it doesn't seem to be working correctly. – David Custer – 2013-05-24T11:17:43.3131@DavidCuster that's an incomplete line of bash - a scripting language primarily used on Linux and OSX. It is possible to get it working on Windows, but probably more effort than it's worth. Look for
Windows batch script
orWindows batch for loop
. Hopefully someone will post a good explanation as an answer - I would do it myself, but I'd have to look up a reference since my Batch scripting is very shaky. – evilsoup – 2013-05-24T17:29:16.303