本帖最后由 flashercs 于 2019-7-17 18:51 编辑
保存为test.bat ,放在Test文件夹所在目录下,双击运行即可。- 0<1/*,:
- @echo off
- cscript -nologo -e:jscript %0
- pause
- exit /b
- */
- ;
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- var wshell = new ActiveXObject('WScript.Shell');
- wshell.CurrentDirectory = fso.GetParentFolderName(WScript.ScriptFullName);
- var srcfile = 'Test\\src';
- var dstfile = 'Test\\dst';
- var tsread = fso.openTextFile(srcfile, 1, false, -2);
- while (!tsread.AtEndOfStream) {
- var strsrc = tsread.ReadAll();
- }
- tsread.close();
- var re = /(\.method\s+.+)[\s\S]*?\.end\s+method/g;
- var arrsrc, objsrc = {};
- while (arrsrc = re.exec(strsrc)) {
- objsrc[arrsrc[1]] = arrsrc[0];
- }
- tsread = fso.openTextFile(dstfile, 1, false, -2);
- while (!tsread.AtEndOfStream) {
- var strdst = tsread.ReadAll();
- }
- tsread.close();
- var tswrite = fso.openTextFile(dstfile, 2, false, -2);
- tswrite.Write(strdst.replace(re, function ($0, $1) {
- return objsrc.hasOwnProperty($1) ? objsrc[$1] : $0;
- }));
- tswrite.close();
- WScript.Echo('Done.');
- WScript.Quit();
复制代码
|