@echo off
setlocal
if "%~1"=="" goto :EOF
set "ffmpeg=C:\FFmpeg\bin\ffmpeg.exe"
set "destDir=C:\FFmpeg\bin\"
if not exist "%ffmpeg%" goto :EOF
if not exist "%destDir%" goto :EOF
set "attributes=%~a1"
if "%attributes:~0,1%"=="d" (
pushd "%~1"
) else (
goto :EOF
)
for %%a in (*.m2ts) do call :hoge "%%~fa"
endlocal
goto :EOF
:hoge
set "outFile=%destDir%%~n1.srt"
if exist "%outFile%" call :fuga "%outFile%"
"%ffmpeg%" -i "%~1" "%outFile%"
exit /b
:fuga
set num=2
:loop
if not exist "%~dpn1 (%num%)%~x1" (
set "outFile=%~dpn1 (%num%)%~x1"
goto :end
)
set /a num+=1
goto :loop
:end
exit /b