- @set @n=0; /* & echo off
- dir /b *.txt | cscript -nologo -e:jscript "%~0" "%~dp0"
- pause & exit/b & rem */
-
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var oExcel = new ActiveXObject("Excel.Application");
- oExcel.Visible = false
- var oBook = oExcel.WorkBooks.Add(); i=1;
- while (!WScript.StdIn.AtEndOfStream) {
- var f = WScript.StdIn.ReadLine();
- var txt = fso.OpenTextFile(f).ReadAll();
- var ar = txt.replace(/\r?\n/g,"\n").split("\n");
- for (var j=0; j<ar.length; j++) {
- oExcel.Cells(i,j+1) = ar[j];
- }
- i+=1;
- }
- oBook.SaveAs(WScript.Arguments(0) + "Result.xls");
- oExcel.WorkBooks.Close();
- oExcel.Quit();
- fso = null; oExcel = null; oBook = null
复制代码
|