REM *************************************************************************
REM MergeSubWithMKV.exe version 0.1
REM -------------------------------------------------------------------------
REM
REM This batchfile will process all *.mkv files within the folder this
REM batchfile is placed in.
REM It will look for subtitle files with the same name as the MKV file.
REM f.e. movie.mkv -> movie.srt
REM
REM If a subtitle is found, then it will be merged with "MKVMerge.exe".
REM The merged MKV file will be placed in subfolder ..\New
REM
REM If no subtitles were found, the MKV file will be copied to folder ..\New
REM This way it is certain the all MKV-files are present in folder ..\New
REM
REM Version history:
REM 0.1 Initial version
REM
REM *************************************************************************
@echo off
setlocal EnableDelayedExpansion
CLS
REM *************************************************************************
REM Create new folder "New" inside current folder.
REM *************************************************************************
md "New" 2>nul
pushd %~dp0
for %%A in (*.mkv) do (
REM *************************************************************************
REM Only one filetype (extension) is processed
REM *************************************************************************
set ext=& for %%X in (idx sub srt) do IF EXIST %%~nA.%%X set ext=%%X
if defined ext (
REM *************************************************************************
REM Merge subtitle *.srt/.sub/.idx into MKV-file with the same name
REM *************************************************************************
"C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpANew\%%~nxA" "%%~fA" "--sub-charset" "0:ISO-8859-2" "--language" "0:dut" "--track-name" "0:Nederlands" "%%~dpnA.!ext!"
) else (
REM *************************************************************************
REM If no subtitle files were found, copy MKV file
REM *************************************************************************
if NOT EXIST "%%~dpANew\%%~nxA" COPY "%%~fA" "%%~dpANew\%%~nxA"
)
REM *************************************************************************
REM Progress of merging files
REM *************************************************************************
Echo File processed: %%~nxA
)
Echo Merged MKV files are copied into subfolder %~dp0New\
pause
popd
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\MKVSubMerge\command]
@="\"C:\\Program files (x86)\\MKVSubMerge\\MKVSubMerge.cmd\" \"%1\\\""
This assumes that the batchfile is named: "MKVSubMerge.cmd"REM *************************************************************************
REM MKVSubMerge.cmd version 0.2
REM -------------------------------------------------------------------------
REM
REM This batchfile will process all *.mkv files within the folder this
REM batchfile is placed in.
REM It will look for subtitle files with the same name as the MKV file.
REM f.e. movie.mkv -> movie.srt
REM
REM If a subtitle is found, then it will be merged with "MKVMerge.exe".
REM The merged MKV file will be placed in subfolder ..\New
REM
REM If no subtitles were found, the MKV file will be copied to folder ..\New
REM This way it is certain the all MKV-files are present in folder ..\New
REM
REM Version history:
REM 0.1 Initial version
REM 0.2 Added functionality to add folder from contextmenu in Window Explorer
REM
REM *************************************************************************
@echo off
setlocal EnableDelayedExpansion
CLS
REM *************************************************************************
REM Create new folder "New" inside current folder.
REM *************************************************************************
md "New" 2>nul
pushd %~dp1
for %%A in (*.mkv) do (
REM *************************************************************************
REM Only one filetype (extension) is processed
REM *************************************************************************
set ext=& for %%X in (idx sub srt) do IF EXIST %%~nA.%%X set ext=%%X
if defined ext (
REM *************************************************************************
REM Merge subtitle *.srt/.sub/.idx into MKV-file with the same name
REM *************************************************************************
"C:\Program Files (x86)\MKVToolNix\mkvmerge.exe" -o "%%~dpANew\%%~nxA" "%%~fA" "--sub-charset" "0:ISO-8859-2" "--language" "0:dut" "--track-name" "0:Nederlands" "%%~dpnA.!ext!"
) else (
REM *************************************************************************
REM If no subtitle files were found, copy MKV file
REM *************************************************************************
if NOT EXIST "%%~dpANew\%%~nxA" (
Echo Making a copy of %%~fA
Echo Please wait ...
COPY "%%~fA" "%%~dpANew\%%~nxA"
)
)
REM *************************************************************************
REM Progress of merging files
REM *************************************************************************
Echo File processed: %%~nxA
)
Echo Merged MKV files are copied into subfolder %~dp1New\
pause
popd
@echo off
set folder=
if "%~1"=="" (
echo No folder selected.
call :getfolder
) ELSE (
if exist "%~1" (
set folder=%~1
) else (
echo Folder not found or you have passed a filename instead
pause
exit /b
)
)
if "%folder%"=="" exit /b
pushd "%folder%
echo Folder is %cd%
REM Put your stuff in here to work from the current directory, or use %folder% for the folder chosen...
pause
exit /b
:GetFolder
(echo Set objShell = CreateObject^( "Shell.Application" ^)
echo set objFolder = objShell.BrowseForFolder^( 0, "Select a folder", ^&H10^&, ""^)
echo if objFolder is nothing then wscript.quit
echo wscript.echo objFolder.Self.Path)> "%temp%\getpath.vbs"
for /f "tokens=*" %%a in ('cscript //nologo "%temp%\getpath.vbs"') do set folder=%%a
exit /b
C:\Users\<username>\AppDat
I'd start by creating a shortcut to your batch file on the desktop and then copy that shortcut to the above location. This way you'll get an extra 'batch' item that answers your 2nd question.
(I'll have to check howto add the directory...)