一个没有什么用的程序.自动替换文件内容,并生成复本.

类别:网站制作 点击:0 评论:0 推荐:

今天我们领导说要做什么GOOGLE的推广,必须把页面上的静态代码和图片给对方,也就是要把所有网页中的ASP代码去掉.
一个一个的改,实在太麻烦了,程序员嘛,怎么做这种千篇一律的工作呢?写程序吧.呵呵.


<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>
set fso=createobject("scripting.filesystemobject")
function rexp(txtval)
  set rexv=new regexp
  rexv.Global=true
  rexv.IgnoreCase=true
  rexv.Multiline=true
  rexv.Pattern="\<\%(.|\s)*?\%\>"
  rexp=rexv.Replace(txtval,"")
end function
sub refile(oFilename,nFilename)
 set fr=fso.OpenTextFile(oFilename)
 set fw=fso.CreateTextFile(nFilename,true)
 fw.write rexp(fr.readall)
 fr.close
 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 & "\" & left(nfile.name,strln) & "htm" else fso.CopyFile 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="">
<INPUT type="text" id=text2 name=text2 value="">
<INPUT type="button" value="Button" id=button1 name=button1 onclick="F_Start(text1.value,text2.value);alert('ok');">
</BODY>
</HTML>

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