本帖最后由 pcl_test 于 2016-6-30 21:24 编辑
- //&cls&dir /a-d/b *.txt|cscript -nologo -e:jscript "%~f0"&pause&exit
- var fso = new ActiveXObject('Scripting.Filesystemobject');
- var txtfiles = WSH.StdIn.ReadAll().split(/\r\n/);
- var n = 2; //指定行
- for(var i = 0; i<txtfiles.length; i++){
- var j=1, txt='';
- var f = fso.OpenTextFile(txtfiles[i], 1);
- while(!f.AtEndOfStream){
- var line = f.Readline();
- if(j==n){
- txt+=line+'\r\n\r\n';
- }else txt+=line+'\r\n';
- j++;
- }
- f.Close();
- var f = fso.OpenTextFile(txtfiles[i], 2);
- f.Write(txt);
- f.Close();
- }
- WSH.echo('Done');
复制代码
|