How can I stop this batch from working with subfolders.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
jdbigguy
Posts: 2
Joined: 28 Mar 2020 22:02
Location: London

How can I stop this batch from working with subfolders.

#1 Post by jdbigguy » 28 Mar 2020 22:30

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
Last edited by Squashman on 29 Mar 2020 13:38, edited 1 time in total.
Reason: MOD EDIT: Please use code tags.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 29 Mar 2020 13:36

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.

jdbigguy
Posts: 2
Joined: 28 Mar 2020 22:02
Location: London

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

#3 Post by jdbigguy » 03 Apr 2020 21:16

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.

Post Reply