- @set @n=0;/* & echo off
- set "fd=D:\数据\新文本\"
- md "%fd%" 2>nul
- pushd D:\数据\
- dir /b *.txt | cscript -nologo -e:jscript "%~0" "%fd%"
- pause & exit
- */
-
- var fd = WScript.Arguments(0);
- var fso = new ActiveXObject('Scripting.FileSystemObject');
-
- while (!WScript.StdIn.AtEndOfStream) {
- var f = WScript.StdIn.ReadLine();
- var arr = readTextFile(f).split('\r\n');
- var str = '';
- for(var i=0; i<arr.length; i++){
- if (!/^\s*$/.test(arr[i])) str += getNum(arr[i]) + '\r\n';
- }
- fso.OpenTextFile(fd + f, 2, true).Write(str)
- }
-
- function readTextFile(strFile) {
- var objFile = fso.OpenTextFile(strFile, 1);
- var s = objFile.ReadAll();
- objFile.Close(); objFile = null;
- return s
- }
-
- function getNum(s) {
- var ar = [];
- for (var i=0; i<=9; i++) {
- ar.push(s.split(i).length + "=" + i);
- }
- ar.sort(function(x,y){return y.split("=")[0]-x.split("=")[0]});
- return ar.join(" ").replace(/\d+=/g, "");
- }
复制代码
|