- //&cls&dir /b *.txt|cscript -nologo -e:jscript "%~f0"&pause&exit
-
- function reStr(file){
- var f = fso.opentextfile(file, 1);
- str = f.ReadAll()
- .replace(/(^[\r\n]*)/g, '行首替换内容\r\n');//行首添加一行内容
- //如果不需要换行替换内容后面的\r\n去掉
- f.Close();
- var f = fso.opentextfile(file, 2);
- f.Write(str);
- }
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- while(!WScript.StdIn.AtEndOfStream)reStr(WScript.StdIn.ReadLine());
复制代码
- //&cls&dir /b *.txt|cscript -nologo -e:jscript "%~f0"&pause&exit
-
- function reStr(file){
- var f = fso.opentextfile(file, 1);
- str = f.ReadAll()
- .replace(/^[\r\n]*|[\r\n]*$/g, '')//删除首尾空行,不需要可删除这行
- .replace(/[\r\n]*$/g, '\r\n行尾替换内容');//行尾添加一行内容,如果不需要换行,替换内容\r\n去掉
- f.Close();
- var f = fso.opentextfile(file, 2);
- f.Write(str);
- }
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- while(!WScript.StdIn.AtEndOfStream)reStr(WScript.StdIn.ReadLine());
复制代码
|