本帖最后由 pcl_test 于 2015-12-9 22:51 编辑
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- while(!WScript.StdIn.AtEndOfStream) {
- var f = WScript.StdIn.ReadLine();
- //替换规则
- var repstr = ['A->1','B->2']
- if(fso.GetFile(f).size>1){
- var txt = fso.OpenTextFile(f, 1).ReadAll();
- for(var i=0; i<repstr.length; i++){
- var t = repstr[i].split('->');
- //需区分字母大小写,把ig的i去掉
- var reg = new RegExp(t[0],'ig');
- txt = txt.replace(reg,t[1]);
- }
- fso.CreateTextFile(f, 2).Write(txt);
- }
- }
复制代码
|