- @set @n=0;//&dir /b *.txt|cscript -nologo -e:jscript "%~0"&pause&exit/b
- a = 1; b = 5; //从倒数第1行到倒数第5行
- x = b-a+1; y = a-1; //x=删除行数,y=结尾剩余行数
- fso = new ActiveXObject("Scripting.FileSystemObject");
- re = new RegExp('^([\\s\\S]*?)(.*\\n){'+x+'}((.*\\n){'+y+'})$','');
- while (!WSH.StdIn.AtEndOfStream) {
- f = WSH.StdIn.ReadLine();
- txt = fso.OpenTextFile(f,1).ReadAll();
- if (txt.substr(txt.length-2) != '\r\n') txt += '\r\n'
- txt = txt.replace(re, '$1$3');
- fso.OpenTextFile(f,2).Write(txt);
- }
复制代码
|