Test.js- var srcFile = '1.txt';
- var dstFile = '2.txt';
-
- var obj = {}
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var str = fso.OpenTextFile(srcFile, 1).ReadAll();
- str = str.replace(
- /^[a-z]+\b/mig,
- function(s){
- if( !obj.hasOwnProperty(s) ) obj[s] = 1;
- return s + obj[s]++;
- }
- );
-
- fso.OpenTextFile(dstFile, 2, true).Write(str);
- WSH.Echo('Done');
复制代码
|