本帖最后由 xp3000 于 2022-1-18 18:19 编辑
- //&cls&dir /b *.txt|cscript -nologo -e:jscript "%~f0"&echo 文本连续行去重复,有4个以上连续字符串不同则保留,可以修改{3,}增加数量&pause&exit
-
- function reStr(file){
- var f = fso.opentextfile(file, 1);
- str = f.ReadAll().replace(/^(.{1,})(.{3,})(.{1,}\r?\n)(.{1,}\2.{1,}\r?\n)+/mg, '$1$2$3')
- .replace(/^(.{1,})(.{3,})(.{1,}\r?\n)(.{1,}\2.{1,}\r?\n)+/mg, '$1$2$3')
- .replace(/^(.{1,})(.{3,})(.{1,}\r?\n)(.{1,}\2.{1,}\r?\n)+/mg, '$1$2$3');
- f.Close();
- var f = fso.opentextfile(file, 2);
- f.Write(str);
- }
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- while(!WScript.StdIn.AtEndOfStream)reStr(WScript.StdIn.ReadLine());
复制代码 BAT和文本都ANSI编码,可以保存ANSI了 |