0

I'm looking for some command / script to scan my designated folder, merge the srt files (same name as video) with avi/mp4/mkv files to get mkv files, and then delete the original files (video AND subtitle).

Now I have this code (not mine, from some authors I combined):

@echo off
for /R %%A IN (*.mkv *.avi *.mp4) do (
"C:\Program Files\MKVToolNix\mkvmerge.exe" -o "%%~nxA_CZ.mkv" "%%~A" "%%~nA.srt"
  if errorlevel 1 (
                echo Warnings/errors generated during remuxing, original file not deleted
            ) else (
                del /f "%%A" "%%~nA.srt"
                echo Successfully remuxed to "%%~dpna (No Subs)%%~xa", original file deleted
            )
            echo.
        )
    )
)

Which kind of works, but I have a few problems.
The /R parameter isn't working, don't know why, but when I place it in a folder with subfolders it only scans the srt files in it and I get a "Can't open" error. (This error also appears for files in a single folder but in the end it does what I need.)

Any idea how to fix my problem?

1
  • Probably need to use FOR /F "TOKENS=*" %%A IN loop using the ('DIR /A-D /B /S "C:\Root"') and then use the output of that with some logic to pick out of the .mp4,.avi, and .mkv files with the DO command. Using something like IF [%%~XA]==[.mkv], etc. and then tell it to do the mkvmerge.exe operation from there accordingly. With some testing you can complete this so get to work and ping me back if you'd like an answer explaining but take your stab at it with that quick idea. Sep 26, 2017 at 15:26

1 Answer 1

0

this is how you should add subtitle:

mkvmerge.exe -o "output.mkv" --audio-tracks 1 --no-subtitles --no-attachments 
--no-chapters --language 0:und --default-track 0:yes --compression 0:none     
--language 1:und --default-track 1:yes --compression 1:none "input.mkv"       
--language 0:und --compression 0:none "input.srt" --track-order 0:0,0:1,1:0   
--probe-range-percentage 0.50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.