本帖最后由 xp3000 于 2023-12-28 14:06 编辑
- //&cls&dir /b *.txt|cscript -nologo -e:jscript "%~f0"&pause&exit
- fso = new ActiveXObject("Scripting.FileSystemObject");
- while (!WSH.StdIn.AtEndOfStream) {
- f = WSH.StdIn.ReadLine();
- content = fso.OpenTextFile(f,1).ReadAll();
- var newContent = '';
- var count = 0;
- // 遍历字符串中的每个字符
- for (var i = 0; i < content.length; i++) {
- var char = content.charAt(i);
- if (char == ' ') {
- count += 1;
- if (count == 4) {
- count = 0;
- newContent += ' ';
- } else {
- newContent += char;
- }
- } else {
- newContent += char;
- }
- }
- fso.OpenTextFile(f,2,true).Write(newContent);
- }
复制代码 效率不高 |