本帖最后由 pcl_test 于 2015-5-20 15:26 编辑
借CrLf大的js库代码弄了这个离线版- @set @n=0; /* & echo off
- md "处理结果\" 2>nul
- dir /b *.html|cscript -nologo -e:jscript "%~0"
- pause & exit/b & rem */
-
- var loadText = function (strFileIn,strCharset){
- try{
- var stream = new ActiveXObject('ADODB.Stream');
- stream.Type = 2;
- stream.Mode = 3;
- stream.Charset = strCharset;
- stream.Open();
- stream.LoadFromFile(strFileIn);
- stream.Position = 0;
- return stream.ReadText;
- }
- catch(Err){}
- }
-
- var saveText = function (strArg,strFileOut,strCharset){
- try{
- var stream = new ActiveXObject('ADODB.Stream');
- stream.Mode = 3;
- stream.Type = 2;
- stream.Charset = strCharset;
- stream.Open();
- stream.WriteText(strArg);
- return stream.SaveToFile(strFileOut,2);
- }
- catch(Err){}
- }
-
- while(!WScript.StdIn.AtEndOfStream){
- var file = WScript.StdIn.ReadLine();
- var HtmlText =loadText(file,'utf-8');
- var FileNameList = loadText('中文名.txt','gb2312').match(/[^\s]+/mg);
- var newHtmlText = HtmlText.replace(/("thumbnailtitle"\>).+?(?=\<\/a)/g,function($0,$1){return $1+FileNameList.shift();});
- saveText(newHtmlText,'./处理结果/new_'+file,'utf-8');
- }
复制代码
|