I am trying to remove subtitles and chapters from all my mkv files. I've been trying to find a way to add the below batch file to also look for chapters and remove them but haven't been able to figure out how to edit the find line. Any help is very much appreciated.
@echo off
cls
set rootfolder=C:\
echo Enumerating all MKVs under %rootfolder%
echo.
for /r %rootfolder% %%a in (*.mkv) do (
for /f %%b in ('mkvmerge -i "%%a" ^| find /c /i "subtitles"') do (
if [%%b]==[0] (
echo "%%a" has no subtitles
) else (
echo.
echo "%%a" has subtitles
mkvmerge -q -o "%%~dpna (No Subs)%%~xa" -S "%%a"
if errorlevel 1 (
echo Warnings/errors generated during remuxing, original file not deleted
) else (
del /f "%%a"
echo Successfully remuxed to "%%~dpna (No Subs)%%~xa", original file deleted
)
echo.
)
)
)
If I rewrite the batch like this. It does what I want but it is sloppy going through the files twice.
@echo off
cls
set rootfolder="D:\uTorrent\Completed Downloads"
echo Enumerating all MKVs under %rootfolder%
echo.
for /r %rootfolder% %%a in (*.mkv) do (
for /f %%b in ('mkvmerge -i "%%a" ^| find /c /i "subtitles" ') do (
if [%%b]==[0] (
echo "%%a" has no subtitles
) else (
echo.
echo "%%a" has subtitles
mkvmerge -q -o "%%~dpna (No Subs)%%~xa" -S --no-chapters "%%a"
if errorlevel 1 (
echo Warnings/errors generated during remuxing, original file not deleted
) else (
del /f "%%a"
echo Successfully remuxed to "%%~dpna (No Subs)%%~xa"
)
echo.
)
)
)
set rootfolder="D:\uTorrent\Completed Downloads"
echo Enumerating all MKVs under %rootfolder%
echo.
for /r %rootfolder% %%a in (*.mkv) do (
for /f %%b in ('mkvmerge -i "%%a" ^| find /c /i "chapters" ') do (
if [%%b]==[0] (
echo "%%a" has no chapters
) else (
echo.
echo "%%a" has chapters
mkvmerge -q -o "%%~dpna (No Chapters)%%~xa" -S --no-chapters "%%a"
if errorlevel 1 (
echo Warnings/errors generated during remuxing, original file not deleted
) else (
del /f "%%a"
echo Successfully remuxed to "%%~dpna (No Chapters)%%~xa"
)
echo.
)
)
)
pause