Page 1 of 1

How can I stop this batch from working with subfolders.

Posted: 28 Mar 2020 22:30
by jdbigguy
Hello, I use the batch file below to remove subtitles from mkv video files. It works really well except it checks all subfolders in "F:\Films.
I don't want to move the subfolders and as there are quite a few,it takes a while to run. So how can I stop this batch from working with the subfolders.

Thanks for your help

Code: Select all

@echo off
cls
set rootfolder=F:\Films
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
            )
            echo.
        )
    )
)
Pause

Re: How can I stop this batch from working with subfolders.

Posted: 29 Mar 2020 13:36
by Squashman
Did you perhaps try to solve the issue yourself by first understanding what the commands you are using actually do? I bet if you read the help for the commands you are using, you will be able to solve this yourself.

Re: How can I stop this batch from working with subfolders.

Posted: 03 Apr 2020 21:16
by jdbigguy
You would lose that bet.

I spent several hours trying to sort this issue before coming here and I made various changes. All made the bat file stop working at all or it simply continued, but without the desired effect.