回复 8# 思想之翼 - @if(0)==(0) echo off
- dir /b /s D:\数据\*.txt | cscript -NoLogo -E:JScript %0 "D:/数据库/" "D:/搜寻/"
- pause & exit
- readFile(filename){ f1.Close();
- @end
- var ting = 6;
- var ph1= WScript.Arguments.Item(0);
- var ph2= WScript.Arguments.Item(1);
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- function readFile(filename, n) {
- var ar = fso.OpenTextFile(filename, n).ReadAll().replace(/\r?\n$/g,'').split("\r\n");
- return ar;
- }
-
- function uniq(ar){
- var j = 0, str = "", obj = {};
- for(var i = 0, l = ar.length; i < l; i++ ){
- var k = ar[i];
- obj[k] = obj[k] > 0 ? obj[k] + 1 :1
- }
- for (var k in obj) str += obj[k] > ting ? k + " ": "";
- return str.replace(/\s+$/g, "");
- }
-
- while (!WScript.StdIn.AtEndOfStream){
- var filename = WScript.StdIn.Readline();
- var text = readFile(filename, 1);
- for(i = 0, len = text.length; i < len; i++ ){
- var ar = [], arr = text[i].split(" ");
- for(var j = 0, l = arr.length; j < l; j++ ){
- var p = j + 1 + "\\"
- p += arr[j] + ".txt"
- ar = ar.concat(readFile(ph1 + p, 1));
- }
- var file = i + 1 + ".txt"
- var f = fso.GetBaseName(filename);
- var Folder = ph2 + f
- if (!fso.FolderExists(Folder)) fso.CreateFolder (Folder);
- var newfile = Folder + "/" + f + "_" + file;
- fso.CreateTextFile(newfile, true).Write(uniq(ar));
- }
- }
复制代码
|