CODE: [Copy to clipboard]
#NoEnv
#SingleInstance force
#Include ws4ahk.ahk
SetBatchLines -1
WS_Initialize("jscript")
loop,%1%
{
__FILE:=A_LoopFileLongPath
StringReplace, __FILE, __FILE, \ , \\, All
Code=
(LTrim
fso=new ActiveXObject("Scripting.FileSystemObject");
try{
var ts=fso.opentextfile("%__FILE%",1,false,-2);
var sss=ts.readall();
ts.close();
}catch(err){
WScript.quit();
}
if(/^LTrim$/i.test("%2%"))sss=sss.replace(/^[ \t]+/mg,'');
else if(/^RTrim$/i.test("%2%"))sss=sss.replace(/[ \t]+$/mg,'');
else if(/^Trim$/i.test("%2%")){
sss=sss.replace(/^[ \t]+/mg,'');
sss=sss.replace(/[ \t]+$/mg,'');
} else {
sss=sss.replace(%2%,"%3%");
}
if (/^U(nicode)?$/i.test("%4%"))
{
try{saveTextAsUnicode(sss,"%__FILE%");}catch(err){}
} else {
try{// try to saving as Ansi
saveTextAsAnsi(sss,"%__FILE%");
}catch(err){// save as Unicode
saveTextAsUnicode(sss,"%__FILE%");
}
}
function saveTextAsAnsi(sss,fname)
{
ts=fso.opentextfile(fname,2,true,0);
ts.write(sss);
ts.close();
}
function saveTextAsUnicode(sss,fname)
{
ts.close();
ts=fso.opentextfile(fname,2,true,-1);
ts.write(sss);
ts.close();
}
)
ws_exec(code)
}
WS_Uninitialize()
[