Trying to create txt files containing specific text

Greetings from Greece!
My question is a bit difficult to answer so I'll need your attention.
I am trying to auto-create txt files, named after the corresponding .MTS files (video) and contain specific text that has a variable in each txt.
Actually I need to automatically create .avs files (avisynth config files - actually txt files renamed to avs) for each of my .MTS (video) files that act as video servers for virtual dub.

Here is an example of the text:

DirectShowSource("#######.MTS")
ConvertToYV12(interlaced=false)

where ######.mts is the name of the corresponding video.
Each txt file must have the same name as the video it represents!
e.g. the 0058.avs file should contain the text:

DirectShowSource("0058.MTS")
ConvertToYV12(interlaced=false)

I managed to auto create the files but I can't make them to pre-contain the text (not to mention to automatically change the name inside the text) using the following button:

@filesfromdroponly
@nodeselect
Clipboard COPYNAMES=nopaths
FileType NEW=.txt FROMCLIPBOARD
Rename FROM ".txt" TO ".avs"

This is where my "talent in scripting " stops. I can't do anything beyond that.
Any help will be appreciated, I have about 200+ video files on each project and it is a real pain to create each .avs file by hand.

Thank you all in advance!
George.

I'd try something like this, make sure button is batch type.

@nofilenamequoting
echo DirectShowSource("{file$}") >"{file$|noext}.avs"
echo ConvertToYV12(interlaced=false) >>"{file$|noext}.avs"
1 Like

OMG Thank you so much!!!! It worked perfectly!

You saved me so many hours of manual copy-pasting my friend!
If you ever come to Rhodes Island (Greece) I promise to pay for all the beers you can drink! :smiley:

THANK YOU AGAIN!!! :thumbsup:

Your welcome! o) Can I get Ouzo instead of beer? o)

You can have all the Ouzo you want! And as tradition dictates, served with sea food :slight_smile: