批量查找/替换,包括子目录,自动备份.简单脚本.

类别:网站制作 点击:0 评论:0 推荐:
<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=JavaScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
<SCRIPT LANGUAGE=javascript>
<!--
//-->
</SCRIPT>
<script language=vbscript>
'头太晕, http://blog.csdn.net/super852  http://spaces.msn.com/members/headfaint/
set fso=createobject("scripting.filesystemobject")
dim oldString
dim newString
sub refile(oFilename,nFilename)
    dim txtfile
    fso.CopyFile ofilename,nfilename
    set fr=fso.OpenTextFile(oFilename)
    txtfile=replace(fr.readall,oldString,newString)
    fr.close
    set fw=fso.OpenTextFile(oFilename,2)
    fw.write txtfile
    fw.close
end sub
sub F_Start(oFolder,nFolder)
    F_StartN oFolder,nFolder
    set FLD=fso.GetFolder(oFolder)
    for each nfile in FLD.files
      astrn=nfile.name
      strln=instrrev(astrn,".asp")
      if strln then  refile ofolder & "\" & nfile.name,nfolder & "\" & nfile.name
    next
end sub

sub F_StartN(oFolder,nFolder)
    set FLD=fso.GetFolder(oFolder)
    for each ifolder in FLD.subfolders
        fso.CreateFolder(nFolder & "\" & ifolder.name)
        F_Start ifolder,nfolder & "\" & ifolder.name
    next
end sub
</script>
</HEAD>

<BODY>
目录:<INPUT type="text" id=text1 name=text1 value=""><br>
备份目录:<INPUT type="text" id=text2 name=text2 value=""><br>
查找:<INPUT type="text" id=text3 name=text3 value=""><br>
替换:<INPUT type="text" id=text4 name=text4 value=""><br>
<INPUT type="button" value="Button" id=button1 name=button1 onclick="oldString=text3.value;newString=text4.value;F_Start(text1.value,text2.value);alert('ok');">
</BODY>
</HTML>

通过修改,可使其支持正则表达式.

本文地址:http://com.8s8s.com/it/it30713.htm