help me with batch scripting

Fayd

Diamond Member
Jun 28, 2001
7,970
2
76
www.manwhoring.com
i'm trying to set up a batch script that will auto-write .avs files for encoding video.

.avs is an avisynth script. it's used for (among other things) overlaying subtitles onto video for hardsubbing.

here's what i have right now.

Code:
FORFILES -m *.mkv -c "CMD /C echo DirectShowSource("@PATH", fps=23.976, audio=false, convertfps=true) >> @FNAME.avs"
FORFILES -m *.avs -c "CMD /C echo LanczosResize(480,272) # Lanczos (Sharp) >> @FILE"
FORFILES -m *.avs -c "CMD /C echo LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\VSFilter.dll") >> @FILE"
FORFILES -m *.ass -c "CMD /C echo TextSub("@PATH", 1) >> @FNAME.avs

this creates a .avs file for every .mkv in the folder, then adds the lines.

the problem is, it completely misses the "loadplugin..." line. i dont get it. every other line works.

i tried before to just use \n to denote a new line, and it wouldnt work either. that would have been preferable... but i'm having difficulty setting absolute path names without breaking it up into different lines.

but i have to have the loadplugin line there...

any ideas?
 
Last edited:

Fayd

Diamond Member
Jun 28, 2001
7,970
2
76
www.manwhoring.com
i've tried using echo. as well, no dice.

i tried using echo by itself just to output to screen, and it passed that line without problem. i can't understand what i'm doing wrong.
 
Last edited:

Ig

Senior member
Mar 29, 2001
236
0
0
Here's what I came up with (use FOR instead of FORFILES):
Code:
for %%F in (*.mkv) do (
	echo DirectShowSource("%%~fF", fps=23.976, audio=false, convertfps=true^) >> %%~nF.avs
)
for %%F in (*.avs) do (
	echo LanczosResize(480,272^) # Lanczos (Sharp^) >> %%F
	echo LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\VSFilter.dll"^) >> %%F
)
for %%F in (*.ass) do (
	echo TextSub("%%~fF", 1^) >> %%~nF.avs
)

Sample output:
Code:
DirectShowSource("B:\temp\test2.mkv", fps=23.976, audio=false, convertfps=true) 
LanczosResize(480,272) # Lanczos (Sharp) 
LoadPlugin("C:\Program Files (x86)\MeGUI\tools\avisynth_plugin\VSFilter.dll") 
TextSub("B:\temp\test2.ass", 1)
 

Fayd

Diamond Member
Jun 28, 2001
7,970
2
76
www.manwhoring.com
i managed to solve it just before you replied... for some reason i *really* dont get, quotation marks around variables are treated differently than quotation marks around simple text. (hence why the first line worked, but the loadplugin line didnt) so, on the loadplugin line, i had to use \ to denote those quote marks as simple quote marks, and not something related to the FORFILES assosciated structure.

as i dont understand scripting in windows (i understand bash, of all things...) the complex variable naming in FOR scared me away from it, and into using FORFILES. i wish it hadn't... the syntax for FOR looks sooo much easier. actually being able to bracket a loop with parenthesis instead of quotation marks... i would have avoided this mess entirely.

thanks for the help though, Ig.