本帖最后由 pcl_test 于 2015-7-7 00:48 编辑
回复 19# Linux9253 - 1>1/* :
- @echo off
- dir /b "测试.txt"|cscript -nologo -e:jscript "%~f0"
- echo 完成!
- ping -n 2 0 >nul&exit/b
- */
-
- function toFile(file){
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var f1 = fso.OpenTextFile(file,1,false);
- var f2 = fso.CreateTextFile("$NEW_"+file,1);
- var txt="";
- while(!f1.AtEndOfStream){
- var str=f1.ReadLine();
- if (str=="rem var1"){
- txt=str+"\r\n"+"测试内容1";
- }else if (str=="rem var2"){
- txt=str+"\r\n"+"测试内容2";
- }else if (str=="rem var3"){
- txt=str+"\r\n"+"测试内容3";
- }else{txt=str;}
- f2.WriteLine(txt);
- }
- f1.Close();
- f2.Close();
- }
-
- while(!WScript.StdIn.AtEndOfStream){
- var f=WScript.StdIn.ReadLine();
- toFile(f);
- }
复制代码
|