Categories
User Help

My Batch script cannot match the cover JPG images when muxing files into a MKV

I wrote the code and I want to use it for my archive. Thanks for helping me improve it.

The folders containing the files are as follows (ex.):

Got folder /S01, /s02, /s0n

/S01/01.mkv, 02.mkv,..., cover.jpg
/S02/01.mkv, 02.mkv,..., cover.jpg

In each subfolder there is a file named cover.jpg that I want to attach to all the files in that folder but I can not modify my code to work properly.

The written code could not identify the cover.jpg in each folder.

Here is the code:

@ECHO OFF
For /R %%A IN (*.mkv
) Do (
  "C:/Program Files/MKVToolNix\mkvmerge.exe" -o "%%~dpnxAtmp" --no- ^
  attachments --no-chapters --no-global-tags --no-subtitles --title ^"^" ^
  --language 0:und --language 1:en --track-name 0: --track-name 1: "%%~fA" ^
  --attachment-name cover.jpg --attachment-mime-type image/jpeg --attach-file ^ 
  "%*cover.jpg"
  if errorlevel 2 ( 
      echo errors generated during remuxing, original file not deleted
    ) else if errorlevel 1 (
      del/f "%%~fA" echo Warnings generated during remuxing to "%%~A", original file deleted
    ) else (
      del/f "%%~fA" echo Successfully remuxed to "%%~A", original file deleted
    ) & for /R %%A IN (*.mkvtmp) do ren "%%~fA" "%**.mkv" & CLS
)
pause

Leave a Reply

Your email address will not be published. Required fields are marked *