# Batch file needs tweaking



## hat (Feb 26, 2016)

I've been using AviSynth for deinterlacing and tetelecining TV series lately, and in the process I have to write many scripts for each episode. I've found a batch file that pretty much automates this, but there is one issue. For example, if my source file is "Monk s01e01.mkv", the script the batch file gives me is named "Monk s01e01.mkv.avs". As the files AviSynth produces go by the name of the AVS script, if I processed the script with that name, the resulting file would be "Monk s01e01.mkv.avi". I need to get the .mkv part out of the .avs script the batch file produces. This is the batch file:


```
for %%n in (*.mkv*) do (
echo setmtmode(5,4^) > "%%n.avs"
echo ffmpegsource2("%%n"^) >> "%%n.avs"
echo setmtmode(2^) >> "%%n.avs"
echo qtgmc(edithreads=2^) >> "%%n.avs"
echo selecteven(^)  >> "%%n.avs"
)
```

So, any way to get the .mkv out of the files produced by this batch file? It really beats having to write a script for each episode individually.


----------



## hat (Feb 26, 2016)

For anyone interested, the folks at VideoHelp found a solution:


```
for %%a in (*.mkv) do (
echo setmtmode(5,4^) > "%%~na.avs"
echo ffmpegsource2("F:\AviSynth Worker\%%a"^) >> "%%~na.avs"
echo setmtmode(2^) >> "%%~na.avs"
echo qtgmc(edithreads=2^) >> "%%~na.avs"
echo selecteven(^)  >> "%%~na.avs"
)
```

This batch file will create a .avs script for every file ending in .mkv, the resulting filename(s) being the name of the .mkv file(s), with the .mkv extension dropped. For example, it sees "Red Dwarf s09e01.mkv", creates a file with the name of "Red Dwarf s09e01.avs" with the following code:


```
setmtmode(5,4) 
ffmpegsource2("F:\AviSynth Worker\Red Dwarf s09e01.mkv") 
setmtmode(2) 
qtgmc(edithreads=2) 
selecteven()
```

This is beyond useful for ripping interlaced DVDs en masse, should you want to deinterlace with AviSynth and QTGMC.


----------

