sed好像不支持utf-8吧。
使用前注意备份。- @set @n=0//& cscript.exe -e:jscript "%~f0" &pause&exit/b
-
- strQuery = "select name from CIM_DataFile where "
- + " drive='E:' and path like '\\\\A\\\\%' and ("
- + "(filename='a' and extension='opf') or "
- + "(filename='dc' and extension='xml'))";
- wmi = new ActiveXObject("WbemScripting.SWbemLocator").ConnectServer();
- colFiles = wmi.ExecQuery(strQuery, "WQL", 48);
- e = new Enumerator(colFiles);
- for (; !e.atEnd(); e.moveNext())
- {
- f = e.item().name;
- s = readtext(f);
- s = s.replace(/<dc:title1>[^<>]*<\/dc:title1>|<dc:title2>[^<>]*<\/dc:title2>|<dc:title3>[^<>]*<\/dc:title3>|<publisher1>[^<>]*<\/publisher1>|<contributor1>[^<>]*<\/dc:contributor1>|<relation1>[^<>]*<\/relation1>/g, '');
- writetext(f, s);
- }
-
- function readtext(file, charset)
- {
- var text;
- var aso = new ActiveXObject('ADODB.Stream');
- aso.Mode = 3;
- aso.Type = 2;
- if (charset) aso.Charset = charset;
- else aso.Charset = 'utf-8';
- aso.Open();
- aso.LoadFromFile(file);
- text = aso.ReadText(-1);
- aso.Close();
- aso = null;
- return text;
- }
-
- function writetext(file, text, charset)
- {
- var aso = new ActiveXObject('ADODB.Stream');
- aso.Mode = 3;
- aso.Type = 2;
- if (charset) aso.Charset = charset;
- else aso.Charset = 'utf-8';
- aso.Open();
- aso.WriteText(text);
- aso.SaveToFile(file, 2);
- aso.Close();
- aso = null;
- }
复制代码
|