JavaScript- //&@cls&start wscript -e:jscript "%~f0"&exit/b
- intNode = -1; //负数-n表示去掉倒数第n段
- f = "C:\\Documents and Settings\\user\\桌面\\a.txt"; //可以只写相对路径
- fso = new ActiveXObject("Scripting.FileSystemObject");
- ts = fso.OpenTextFile(f);
- s = '';
- while (!ts.AtEndOfStream)
- s += remove(ts.ReadLine()) + '\n';
- //WScript.Echo(s);
- fso.OpenTextFile('b.txt',2,true).Write(s);
-
- function remove(ss) {
- var arr = ss.split('.').join('-').split('-');
- if(intNode>0) {var n=intNode-1;} else {var n=arr.length+intNode}
- arr.splice(n,1);
- return arr.join(' ');
- }
复制代码
|