VideoHelp Forum
+ Reply to Thread
Results 1 to 10 of 10
Thread
  1. Member
    Join Date
    Nov 2019
    Location
    MInnesota
    Search Comp PM
    64 bit - Windows 10 Pro - MKVToolNix V38.0.0

    I've got a season of anime that I ripped to edit using a batch. This batch renames the title of the MKV to the file name. It also removes unwanted audio and subtitle tracks.

    ```
    dir/b/s *.mkv >list.txt for /F "delims=;" %%F in (list.txt) do "C:\Program Files\mkvtoolnix\mkvpropedit" "%%F" --edit info --set "title=%%~nF" del list.txt

    FOR /F "delims=*" %%A IN ('dir /b *.MKV') DO "C:\Program Files\MKVToolNix\mkvmerge.exe" -o "fixed_%%A" -a !1,2,4 -s !5,6 --compression -1:none "%%A" mkvmerge -o "${file%.mkv}".nosubs.mkv --no-subtitles "$file" PAUSE
    ```

    Now I force in an Srt externally to the new (fixed_) file. To do that I transfer the fixed MKV and external Srt into a new folder and use this batch.

    ```
    for %%A IN (*.mkv) do ( "C:\Program Files\MKVToolNix\mkvmerge.exe" -o "remux-%%~nxA" "%%~A" --forced-track "0:yes" --default-track "0:yes" --track-name "0:English" --language "0:eng" "%%~nA.srt" )
    ```
    It gets the job done but I always end up having two copies at the end. The fixed and the remux MKV files. Its very draining to continually move the fixed files in to a new folder to get it remuxed. It's also sucks to type in the audio and subtitle track numbers I don't want. A show of mine has 19 total subtitles for each episode. I have to type 2-19 in the code just to keep the first track. I was wondering if my two batches could be merged into one batch file.

    This batch would change the the MKV title to the file name, it would keep 1 specific audio or subtitle track without needing to list the ones I don't want, lastly it would insert that external Srt in. All of this will be done from the source file to the edited copy.

    Thanks
    Image
    [Attachment 50734 - Click to enlarge]
    Quote Quote  
  2. Code:
    for %%a in (*.mkv) do mkvmerge --title "%%~na" -o "fixed\%%~a" -a 3 -s 7 "%%~a" --forced-track "0:yes" --default-track "0:yes" --language "0:eng" "%%~na.srt"
    (Keeps audio with TrackID 3 and subtitle with TrackID 7. Don't use the "!" operator to reverse the meaning from "remove" to "keep only".)
    Quote Quote  
  3. Member
    Join Date
    Nov 2019
    Location
    MInnesota
    Search Comp PM
    I appreciate the advice on removing tracks from an MKV file. Now I just need one full code to add the whole process together.
    Quote Quote  
  4. What is not "full" about my code? I think it already fullfills all your requirements. It sets the title, removes unwanted tracks and adds the srt.
    Quote Quote  
  5. Member
    Join Date
    Nov 2019
    Location
    MInnesota
    Search Comp PM
    Originally Posted by sneaker View Post
    What is not "full" about my code? I think it already fullfills all your requirements. It sets the title, removes unwanted tracks and adds the srt.
    Really? Sorry, I thought you were advising me to to just remove the ! in the tracks for this code.

    Code:
    FOR /F "delims=*" %%A IN ('dir /b *.MKV') DO "C:\Program Files\MKVToolNix\mkvmerge.exe" -o "fixed_%%A" -a !1,2,4 -s !5,6 --compression -1:none "%%A" mkvmerge -o "${file%.mkv}".nosubs.mkv --no-subtitles "$file" PAUSE
    If the code you just gave me works for all my processes, how would I add a path for MKVtoolnix and it's utilities in my .bat file. I saved your code into a new batch file but nothing happens so i assume it needs a path.
    Quote Quote  
  6. Replace "mkvmerge" by the full path "C:\Program Files\MKVToolNix\mkvmerge.exe".
    (I have the MKVToolNix folder in %PATH% so I don't need it on my PC.)
    Quote Quote  
  7. Member
    Join Date
    Nov 2019
    Location
    MInnesota
    Search Comp PM
    Originally Posted by sneaker View Post
    Replace "mkvmerge" by the full path "C:\Program Files\MKVToolNix\mkvmerge.exe".
    (I have the MKVToolNix folder in %PATH% so I don't need it on my PC.)
    Thank you soooooo much. I would buy your a beer any day my friend!!!!. I should probably try to learn code as well. Redundancy can be removed by one small sentence, kinda mind blowing.
    Quote Quote  
  8. Member
    Join Date
    Nov 2019
    Location
    MInnesota
    Search Comp PM
    Originally Posted by sneaker View Post
    Replace "mkvmerge" by the full path "C:\Program Files\MKVToolNix\mkvmerge.exe".
    (I have the MKVToolNix folder in %PATH% so I don't need it on my PC.)
    One more question. When I add two audio tracks, it always plays the first one. It makes sense but how can choose which audio track is primary and which is secondary through a batch?
    Quote Quote  
  9. It depends on your player and how you set it up. Depending on that it might select the tracks from the order (TrackID), from the language, quality (e.g. 5.1 FLAC over 2.0 MP3), default/forced flags, track title ...

    See documentation of your player. From mkvmerge doc see --track-order option.
    Quote Quote  
  10. Member
    Join Date
    Nov 2019
    Location
    MInnesota
    Search Comp PM
    Originally Posted by sneaker View Post
    It depends on your player and how you set it up. Depending on that it might select the tracks from the order (TrackID), from the language, quality (e.g. 5.1 FLAC over 2.0 MP3), default/forced flags, track title ...

    See documentation of your player. From mkvmerge doc see --track-order option.
    I see, I think I'm going to use handbrake for this process. Once again, I really appreciate it.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!