本帖最后由 apang 于 2014-8-28 10:36 编辑
更改第2行x的值- @set @n=0;/* & echo off
- set "x=3"
- md "文件夹2" 2>nul
- pushd "文件夹1\"
- dir /b *.txt|cscript -nologo -e:jscript "%~0" "%x%"
- pause & exit/b & rem */
-
- fso = new ActiveXObject("Scripting.FileSystemObject");
- while (!WScript.StdIn.AtEndOfStream) {
- f = WScript.StdIn.ReadLine();
- txt = fso.OpenTextFile(f, 1).ReadAll();
- txt = getMaxNum(txt, WScript.Arguments(0));
- txt = txt.replace(/^\d+ /mg, "");
- fso.CreateTextFile("..\\文件夹2\\"+f, true).Write(txt);
- }
-
- function getMaxNum(str, arg) {
- dic = new ActiveXObject("Scripting.Dictionary");
- for (i=100; i<=199; i++) {
- num = (i + "").substr(1);
- k = str.split(num).length;
- if (k > 1) {
- if (dic.Exists(k)) {
- dic.Item(k) += " " + num
- } else dic.Add(k, k + " " + num)
- }
- }
-
- arItem = (new VBArray(dic.Items())).toArray();
- s = "";
-
- arItem.sort(function(x,y) {return y.split(" ")[0]-x.split(" ")[0]});
- if (arg > arItem.length) arg = arItem.length;
- for (i=0; i<arg; i++) {
- s += arItem[i] + "\r\n";
- }
- return s
- }
复制代码
|