REM ===========================
REM Configuration
REM ===========================
REM Destination directory where processed files will be saved
set "DEST_DIR=D:\Video\MKVConvert"
REM Path to the mkvmerge executable
set "MKVMERGE=C:\Program Files\MKVToolNix\mkvmerge.exe"
REM ===========================
REM Setup
REM ===========================
REM Create destination directory if it does not already exist
if not exist "%DEST_DIR%" (
echo Creating destination directory: "%DEST_DIR%"
mkdir "%DEST_DIR%"
if errorlevel 1 (
echo Error: Failed to create destination directory.
echo Please check permissions or the path and try again.
echo.
pause
)
) else (
REM Suppress success message by doing nothing
REM echo Destination directory exists: "%DEST_DIR%"
)
REM Check if mkvmerge exists
if not exist "%MKVMERGE%" (
echo Error: mkvmerge executable not found at "%MKVMERGE%".
echo Please verify the path to mkvmerge.exe.
echo.
pause
) else (
REM Suppress success message by doing nothing
REM echo Found mkvmerge executable at "%MKVMERGE%".
)
REM ===========================
REM Processing
REM ===========================
REM Loop through each MKV file in the current directory
for %%a in (*.mkv) do (
REM Check if the output file already exists
if exist "%DEST_DIR%%%~na.mkv" (
echo Warning: Output file "%DEST_DIR%%%~na.mkv" already exists. Skipping...
) else (
REM Display a message indicating processing
echo Processing: "%%~nxa"
code
REM Execute mkvmerge to process the file
"%MKVMERGE%" ^
--ui-language en ^
--priority highest ^
--video-tracks 0 ^
--audio-tracks 1 ^
--no-subtitles ^
--no-attachments ^
--no-global-tags ^
--no-track-tags ^
--no-chapters ^
--language 0:en ^
--track-name 0: ^
--default-track-flag 0:yes ^
--language 1:en ^
--track-name 1: ^
--title "" ^
--track-order 0:0,0:1 ^
--output "%DEST_DIR%\%%~nxa" ^
"%%~fa"
REM Check if the processing was successful
if errorlevel 1 (
echo Error: Failed to process "%%~nxa". Please check the input file and try again.
) else (
echo Successfully processed "%%~nxa" and saved as "%DEST_DIR%\%%~na.mkv"
)
)
Assistant
)
REM ===========================
REM Completion Message
REM ===========================
REM Display a completion message for processing
echo.
echo All MKV files have been processed and saved in %DEST_DIR%.
REM Pause the script to allow the user to see the output
pause
It says this when ran:
Processing: "The Cleveland Show (2009) - S02E02 - Cleveland Live.mkv"
mkvmerge v86.0 ('Winter') 64-bit
'D:\Video\The Cleveland Show (2009) - S02E02 - Cleveland Live.mkv': Using the demultiplexer for the format 'Matroska'.
'D:\Video\The Cleveland Show (2009) - S02E02 - Cleveland Live.mkv' track 0: Using the output module for the format 'HEVC/H.265'.
'D:\Video\The Cleveland Show (2009) - S02E02 - Cleveland Live.mkv' track 1: Using the output module for the format 'AAC'.
The file 'D:\Video\MKVConvert\The Cleveland Show (2009) - S02E02 - Cleveland Live.mkv' has been opened for writing.
Multiplexing took 0 seconds.
Successfully processed "The Cleveland Show (2009) - S02E02 - Cleveland Live.mkv" and saved as "D:\Video\MKVConvert\The Cleveland Show (2009) - S02E02 - Cleveland Live.mkv"
Processing: "The Cleveland Show (2009) - S02E09 - Beer Walk.mkv"
mkvmerge v86.0 ('Winter') 64-bit
'D:\Video\The Cleveland Show (2009) - S02E09 - Beer Walk.mkv': Using the demultiplexer for the format 'Matroska'.
'D:\Video\The Cleveland Show (2009) - S02E09 - Beer Walk.mkv' track 0: Using the output module for the format 'HEVC/H.265'.
'D:\Video\The Cleveland Show (2009) - S02E09 - Beer Walk.mkv' track 1: Using the output module for the format 'AAC'.
The file 'D:\Video\MKVConvert\The Cleveland Show (2009) - S02E09 - Beer Walk.mkv' has been opened for writing.
Multiplexing took 0 seconds.
Successfully processed "The Cleveland Show (2009) - S02E09 - Beer Walk.mkv" and saved as "D:\Video\MKVConvert\The Cleveland Show (2009) - S02E09 - Beer Walk.mkv"
Processing: "The Cleveland Show (2009) - S03E02 - The Hurricane.mkv"
mkvmerge v86.0 ('Winter') 64-bit
'D:\Video\The Cleveland Show (2009) - S03E02 - The Hurricane.mkv': Using the demultiplexer for the format 'Matroska'.
'D:\Video\The Cleveland Show (2009) - S03E02 - The Hurricane.mkv' track 0: Using the output module for the format 'HEVC/H.265'.
'D:\Video\The Cleveland Show (2009) - S03E02 - The Hurricane.mkv' track 1: Using the output module for the format 'AAC'.
The file 'D:\Video\MKVConvert\The Cleveland Show (2009) - S03E02 - The Hurricane.mkv' has been opened for writing.
Multiplexing took 0 seconds.
Successfully processed "The Cleveland Show (2009) - S03E02 - The Hurricane.mkv" and saved as "D:\Video\MKVConvert\The Cleveland Show (2009) - S03E02 - The Hurricane.mkv"
Processing: "The Cleveland Show (2009) - S03E16 - Frapp Attack.mkv"
mkvmerge v86.0 ('Winter') 64-bit
'D:\Video\The Cleveland Show (2009) - S03E16 - Frapp Attack.mkv': Using the demultiplexer for the format 'Matroska'.
'D:\Video\The Cleveland Show (2009) - S03E16 - Frapp Attack.mkv' track 0: Using the output module for the format 'HEVC/H.265'.
'D:\Video\The Cleveland Show (2009) - S03E16 - Frapp Attack.mkv' track 1: Using the output module for the format 'AAC'.
The file 'D:\Video\MKVConvert\The Cleveland Show (2009) - S03E16 - Frapp Attack.mkv' has been opened for writing.
Multiplexing took 0 seconds.
Successfully processed "The Cleveland Show (2009) - S03E16 - Frapp Attack.mkv" and saved as "D:\Video\MKVConvert\The Cleveland Show (2009) - S03E16 - Frapp Attack.mkv"
Processing: "The Cleveland Show (2009) - S04E12 - Pins, Spins and Fins.mkv"
mkvmerge v86.0 ('Winter') 64-bit
'D:\Video\The Cleveland Show (2009) - S04E12 - Pins, Spins and Fins.mkv': Using the demultiplexer for the format 'Matroska'.
'D:\Video\The Cleveland Show (2009) - S04E12 - Pins, Spins and Fins.mkv' track 0: Using the output module for the format 'HEVC/H.265'.
'D:\Video\The Cleveland Show (2009) - S04E12 - Pins, Spins and Fins.mkv' track 1: Using the output module for the format 'AAC'.
The file 'D:\Video\MKVConvert\The Cleveland Show (2009) - S04E12 - Pins, Spins and Fins.mkv' has been opened for writing.
Multiplexing took 0 seconds.
Successfully processed "The Cleveland Show (2009) - S04E12 - Pins, Spins and Fins.mkv" and saved as "D:\Video\MKVConvert\The Cleveland Show (2009) - S04E12 - Pins, Spins and Fins.mkv"
Processing: "The Cleveland Show (2009) - S04E23 - Wheel Of Family.mkv"
mkvmerge v86.0 ('Winter') 64-bit
'D:\Video\The Cleveland Show (2009) - S04E23 - Wheel Of Family.mkv': Using the demultiplexer for the format 'Matroska'.
'D:\Video\The Cleveland Show (2009) - S04E23 - Wheel Of Family.mkv' track 0: Using the output module for the format 'HEVC/H.265'.
'D:\Video\The Cleveland Show (2009) - S04E23 - Wheel Of Family.mkv' track 1: Using the output module for the format 'AAC'.
The file 'D:\Video\MKVConvert\The Cleveland Show (2009) - S04E23 - Wheel Of Family.mkv' has been opened for writing.
Multiplexing took 0 seconds.
Successfully processed "The Cleveland Show (2009) - S04E23 - Wheel Of Family.mkv" and saved as "D:\Video\MKVConvert\The Cleveland Show (2009) - S04E23 - Wheel Of Family.mkv"
All MKV files have been processed and saved in D:\Video\MKVConvert.
Press any key to continue . . .
Your batch script appears to execute without errors and successfully processes each MKV file by using mkvmerge to remultiplex specific tracks into the destination directory. However, there are a few points to consider based on the output you've provided:
1. Multiplexing Took 0 Seconds
Issue:
The message "Multiplexing took 0 seconds." suggests that mkvmerge didn't perform any substantial processing on the files. This can happen if the input and output configurations are identical or if mkvmerge determines that no changes are necessary.
Possible Reasons:
No Actual Changes Needed: If the selected tracks and parameters exactly match what's already in the source file, mkvmerge might not need to make any changes, resulting in negligible processing time.
Track Selection Issues: If the track indices specified (--video-tracks 0 and --audio-tracks 1) don't correspond to the actual tracks in your MKV files, mkvmerge might be skipping processing because it's not modifying or selecting any tracks.
Recommendations:
Verify Track Indices: Ensure that --video-tracks 0 and --audio-tracks 1 correctly correspond to the desired video and audio tracks in your MKV files. You can inspect the tracks in an MKV file using tools like MKVToolNix GUI or by running mkvmerge -i "YourFile.mkv" to list the tracks.
batch
mkvmerge -i "YourFile.mkv"
Check for Differences: If you intend to make modifications (like changing language flags, track names, etc.), ensure that these changes are actually being applied. If the source files already meet the desired specifications, mkvmerge won't alter them.
2. Script Functionality vs. Expectations
Observation:
Based on your script and output, mkvmerge is essentially copying the selected tracks to a new file in the destination directory without making any modifications. This is expected behavior for a remultiplexing operation where no transcoding or editing is involved.
Understanding mkvmerge:mkvmerge is primarily a multiplexer. It combines existing streams (video, audio, subtitles, etc.) into a new MKV container without altering the streams themselves. If you need to transcode (e.g., convert video from one codec to another), mkvmerge won't perform that action. For transcoding, tools like FFmpeg are more appropriate.
3. Batch Script Enhancements
While the script functions as intended for remultiplexing, here are some enhancements and best practices to consider:
Exit After Critical Errors:
After encountering a critical error (like failing to create the destination directory or not finding mkvmerge), it's good practice to exit the script to prevent further unintended operations.
batch
if errorlevel 1 (
echo Error: Failed to create destination directory.
echo Please check permissions or the path and try again.
echo.
pause
exit /b 1
)
Handling Empty Track Names and Titles:
Specifying empty strings for --track-name and --title might lead to unintended behavior. If you don't want to set these properties, consider omitting these options.
batch
REM Example: Remove --title and --track-name if not needed
"%MKVMERGE%" ^
--ui-language en ^
--priority highest ^
--video-tracks 0 ^
--audio-tracks 1 ^
--no-subtitles ^
--no-attachments ^
--no-global-tags ^
--no-track-tags ^
--no-chapters ^
--language 0:en ^
--default-track-flag 0:yes ^
--language 1:en ^
--track-order 0:0,0:1 ^
--output "%DEST_DIR%\%%~nxa" ^
"%%~fa"
Logging Detailed Information:
For better troubleshooting and verification, consider logging more detailed information about each processing step, such as track information before and after processing.
4. Example Adjustment for Track Indices
If you find that your audio track is actually 0 instead of 1, adjust the script accordingly:
batch
REM Example adjustment if audio track is 0
"%MKVMERGE%" ^
--ui-language en ^
--priority highest ^
--video-tracks 0 ^
--audio-tracks 0 ^
--no-subtitles ^
--no-attachments ^
--no-global-tags ^
--no-track-tags ^
--no-chapters ^
--language 0:en ^
--default-track-flag 0:yes ^
--language 1:en ^
--track-order 0:0,0:1 ^
--output "%DEST_DIR%\%%~nxa" ^
"%%~fa"
5. Final Considerations
Purpose Clarification: Make sure that mkvmerge aligns with your intended outcome. If you plan to modify the content of the streams (e.g., changing codecs, altering audio/video properties), you'll need to integrate a transcoding tool into your workflow.
Performance Monitoring: The "Multiplexing took 0 seconds." message indicates that mkvmerge didn't perform any substantial processing. If this isn't the expected outcome, revisit the track selections and parameters to ensure meaningful operations are being requested.
If you provide more details about what you expect the script to do versus its current behavior, I can offer more targeted assistance.