原始需求:
http://www.bathome.net/thread-27183-1-1.html- @set @bathome=1 /*
- @echo off
- dir /b a.txt | cscript.exe -nologo -e:jscript "%~f0"
- pause
- goto :eof
- rem */
-
- // JScript starts from here
- while (!WSH.StdIn.AtEndOfStream) {
- f = WSH.StdIn.ReadLine();
- WSH.StdOut.Write("\rHandling:\t"+f);
- try {
- ChangeContent(f);
- WSH.StdOut.Write("\rSuccess:\n");
- }
- catch(e) {
- WSH.StdOut.Write("\rFail:\n");
- }
- }
-
- function ChangeContent(file) {
- var aso, txt;
- aso = new ActiveXObject("ADODB.Stream");
- aso.Mode = 3;
- aso.Type = 2;
- aso.Charset = "cp437";
- aso.Open();
- aso.LoadFromFile(file);
- txt = aso.ReadText(-1);
- if (txt.indexOf('\x00') > -1) {
- aso.Position = 0;
- aso.Charset = "unicode";
- txt = aso.ReadText(-1);
- }
- txt = txt.replace(/<\d+>/g,"")
- aso.Position = 0;
- aso.WriteText(txt);
- aso.SetEOS();
- aso.SaveToFile(file + ".new", 2);
- aso.Close();
- aso = null;
- return txt;
- }
复制代码 参考代码:
http://bbs.bathome.net/viewthread.php?tid=27060#pid139641 |