this is a bit clumsy cos I just dashed it off quickly, but instead of entering the text into the script, loop through the files.
And instead of looping through each line, just work with the requisite strings (should be faster)
fileselectfolder, myfolder, *%a_workingdir%
tooltip, %a_index% - %a_loopfilename%
stringreplace, newfile, newfile, `., _.,all
stringleft, xx, a_loopreadline,1
stringupper, xx, xx
stringtrimleft, yy, a_loopreadline, 1
tmp_.= xx . yy . "`n"
fileappend, %tmp_%, %myfolder%\%newfile%
input files must be text, and output will be to a new file ie output from SOURCEFILE.TXT will be to SOURCEFILE_.TXT