本帖最后由 terse 于 2022-11-22 16:20 编辑
处理D盘DATA文件夹的文件 要修改一下代码 加个过滤- @if(0)==(0) echo off
- cd /d "D:\data\"
- dir /b /a-d "*.txt" | findstr /ixv "统计.txt" | cscript.exe //NoLogo //E:JScript %0
- pause&goto:eof
- rem 保存为ANSI文件
- @end
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var obj = {},f = "统计.txt";
- while( !WSH.StdIn.AtEndOfStream ){
- var file = WSH.StdIn.ReadLine();
- var fi = fso.OpenTextFile(file, 1);
- var text = fi.ReadAll().replace(/[\r\n\s]/gm,'').split('');
- fi.Close();
- for(var i=0,len = text.length; i < len; i++) {
- var tmp = text[i];
- obj[tmp] = (obj[tmp] > 0 ) ? obj[tmp] + 1 : 1;
- }
- }
- var result = '';
- for (var k in obj) { if (obj[k]>2) { result += ( result=='' ) ? k : " " + k } }
- fso.CreateTextFile(f, true).Write( result );
- WSH.Echo('重复数据:',result)
复制代码
- @echo off
- rem 保存为ANSI文件
- cd /d "d:\data\"
- dir /b /a-d "*.txt" | findstr /ixv "统计.txt" | gawk "{for(i=1;i<=NF;i++)a[$i]++}END{for(x in a) if (a[x] >2) printf x FS}" *.txt >"统计.txt"
- pause
复制代码
|