Use for
e sub-rotinas:
for %%i in (%mypath%\*.mkv) do call :genavs "%%~i"
goto :eof
:genavs
set movie=%~1
set moviedir=%~dp1
(
echo loadplugin("%moviedir%\bin\FFMS2.dll")
echo B=FFAudioSource("%movie%")
echo A=FFVideoSource("%movie%").assumefps(%myfps%)
echo AudioDub(A, B)
echo ConvertAudioTo16bit()
echo ConvertToRGB32()
) >> "%movie%.avs"
goto :eof