本帖最后由 terse 于 2015-6-14 11:42 编辑
回复 25# idctop
重新整理一下代码- @if(0)==(0) echo off
- set str="code,name,description,market,suggestion,closing_price,price,exchange rate,price earnings ratio,the main cost,institutional participation"
- for /f "delims=" %%i in ('dir /b *.txt ^| cscript -nologo -e:jscript %0 %str%') do (
- rem 这里是要处理文件
- echo %%i
- )
- pause & exit
- @end
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- var s = WScript.Arguments.Item(0);
- var r = /^.+?(\d{4}(-\d{2}){2})(((\s|-)(\d{2})){2})?.+$/;
- var re = new RegExp("^" + s, "i");
- var reg = /.*\[标签:内容\].*/g;
- var fso = new ActiveXObject("Scripting.FileSystemObject");
- while (!WScript.StdIn.AtEndOfStream){
- var filename = WScript.StdIn.Readline();
- var str = filename.replace(
- r,
- function(a,b,c,d) {return(b + d.replace(/-/,':').replace(/\s+/,',') + ',' );
- }
- )
-
- var text = adoLoadText(filename, 'UTF-8').replace(/\r?\n/ig,'');
- while (!(re.test(text))){
- text = s + "\r\n" + text.replace(/&sbquo/ig,',').replace(/","/g,'\r\n' + str).replace(reg,'');
- TextToFile(text, filename);
- WSH.Echo(filename)
- }
- }
-
- function adoLoadText(filename, charset) {
- var fs, text;
- fs = new ActiveXObject("ADODB.Stream");
- fs.type = 2;
- fs.charset = charset;
- fs.open();
- fs.loadFromFile(filename);
- text = fs.readText(-1);
- fs.close();
- return text;
- }
-
- function TextToFile(text, filename) {
- var fs = new ActiveXObject("Adodb.Stream");
- fs.Charset = 'UTF-8';
- fs.Open();
- fs.WriteText(text);
- fs.SaveToFile(filename, 2);
- fs.Close();
- }
复制代码
|