NateMac00

mkv-reorder bat

May 12th, 2026
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.20 KB | None | 0 0
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3.  
  4. set "SCRIPT_DIR=%~dp0"
  5. set "PS_SCRIPT=%SCRIPT_DIR%mkv-reorder.ps1"
  6.  
  7. if not exist "%PS_SCRIPT%" (
  8.     echo ERROR: mkv-reorder.ps1 not found next to this batch file.
  9.     echo Expected: %PS_SCRIPT%
  10.     pause
  11.     exit /b 1
  12. )
  13.  
  14. :checkdeps
  15. set "MKVMERGE="
  16. if exist "C:\Program Files\MKVToolNix\mkvmerge.exe" set "MKVMERGE=C:\Program Files\MKVToolNix\mkvmerge.exe"
  17. if not defined MKVMERGE if exist "C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" set "MKVMERGE=C:\Program Files (x86)\MKVToolNix\mkvmerge.exe"
  18. if not defined MKVMERGE for /f "delims=" %%i in ('where mkvmerge.exe 2^>nul') do set "MKVMERGE=%%i"
  19.  
  20. if not defined MKVMERGE (
  21.     echo.
  22.     echo ============================================================
  23.     echo  MKVToolNix is required but was not found.
  24.     echo ============================================================
  25.     echo.
  26.     set /p "INSTALL=Install MKVToolNix automatically via winget? [Y/N]: "
  27.     if /i "!INSTALL!"=="Y" goto install
  28.     echo.
  29.     echo Please install MKVToolNix manually from:
  30.     echo   https://mkvtoolnix.download/
  31.     echo.
  32.     pause
  33.     exit /b 1
  34. )
  35. goto run
  36.  
  37. :install
  38. where winget >nul 2>&1
  39. if errorlevel 1 (
  40.     echo.
  41.     echo winget is not available on this system ^(requires Windows 10 1709+ or Windows 11^).
  42.     echo Please install MKVToolNix manually from:
  43.     echo   https://mkvtoolnix.download/
  44.     echo.
  45.     pause
  46.     exit /b 1
  47. )
  48. echo.
  49. echo Installing MKVToolNix via winget...
  50. echo.
  51. winget install --id MoritzBunkus.MKVToolNix -e --accept-source-agreements --accept-package-agreements
  52. if errorlevel 1 (
  53.     echo.
  54.     echo Installation failed.
  55.     echo Please install manually from: https://mkvtoolnix.download/
  56.     echo.
  57.     pause
  58.     exit /b 1
  59. )
  60. echo.
  61. echo Install complete. Continuing...
  62. echo.
  63. goto checkdeps
  64.  
  65. :run
  66. if "%~1"=="" (
  67.     echo.
  68.     echo Usage:
  69.     echo   Drag an MKV file onto this batch file, or run:
  70.     echo   mkv-reorder.bat "path\to\file.mkv" [--no-backup] [--dry-run]
  71.     echo.
  72.     pause
  73.     exit /b 1
  74. )
  75.  
  76. powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%PS_SCRIPT%" -FilePath "%~1" %2 %3 %4 %5 %6
  77. set "PSEXIT=%ERRORLEVEL%"
  78.  
  79. echo.
  80. pause
  81. exit /b %PSEXIT%
  82.  
Advertisement
Add Comment
Please, Sign In to add comment