替换AA.js ,放到1.txt 2.txt同目录,生成结果3.txt- var fso = WScript.CreateObject('Scripting.FileSystemObject');
- var file1 = '1.txt';
- var file2 = '2.txt';
- var file3 = '3.txt';
- var curDir = WScript.CreateObject('WScript.Shell').CurrentDirectory = fso.GetParentFolderName(WScript.ScriptFullName);
- var ts1 = fso.OpenTextFile(file1, 1, false, -2);
- var ts2 = fso.OpenTextFile(file2, 1, false, -2);
- var ts3 = fso.OpenTextFile(file3, 2, true, -2);
- if (!ts2.AtEndOfStream) {
- ts3.Write(ts2.ReadAll().replace(/AA/g, function ($0) {
- return ts1.AtEndOfStream ? $0 : ts1.ReadLine();
- }));
- }
- ts1.close();
- ts2.close();
- ts3.close();
复制代码
|