<%Server.ScriptTimeOut=9999%>
<%

	Dim ConnStr ',DB
	Db = "/data/codedown.mdb"
	ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(db)   '数据库地址，存下载要处理文件的文件名
	'On Error Resume Next
	Set conn = Server.CreateObject("ADODB.Connection")
	conn.open ConnStr
	If Err Then
		err.Clear
		Set Conn = Nothing
		Response.Write "数据库连接出错，请检查连接字串。"
		Response.End
	End If
	
if Request("action") = "make" then

		startid = cint(Request("startid"))
		endid = cint(Request("endid"))
		folders = Request("folders")
		files = Request("files")
		
	if endid > startid and folders <> "" and files <> "" then
		
		Set fso=Server.CreateObject("Scripting.FileSystemObject")
		
		set rs = conn.execute("select savefile from codedown")

		i = 0

		do while NOT RS.EOF
			
			if right(rs(0),4) = ".zip" or right(rs(0),4) = ".ZIP" then
				IF fso.FileExists( folders & trim(rs(0))) then
				
					str = str & "echo 正在处理 " & rs(0) & "..." & vbcrlf
					str = str & "C:\winrar.exe d -inul -ibck " & folders & rs(0) & " chinaz.com.txt" & vbcrlf    '删除文件
					str = str & "C:\winrar.exe d -inul -ibck " & folders & rs(0) & " 说明.htm" & vbcrlf
					str = str & "C:\winrar.exe d -inul -ibck " & folders & rs(0) & " cnzzz.com.txt" & vbcrlf
					str = str & "C:\winrar.exe d -inul -ibck " & folders & rs(0) & " 中国站长站.url" & vbcrlf
					str = str & "C:\winrar.exe a -inul -ibck " & folders & Rs(0) & " f:\说明.htm" & vbCrLf       '添加文件
					str = str & "C:\winrar.exe a -inul -ibck " & folders & Rs(0) & " f:\gvstudio.net.txt" & vbCrLf
					str = str & "C:\winrar.exe a -inul -ibck " & folders & Rs(0) & " f:\软件_源码_绿叶网络传媒(下载站).url" & vbCrLf
					str = str & "C:\winrar.exe c -inul -ibck -zh:\gvstudio.net.txt " & folders & Rs(0) & "" & vbCrLf   '添加注释
					str = str & "echo 处理完毕 " & vbcrlf
					i = i + 1
					
				END IF
			end if
			
			rs.movenext
		loop

	Call makebat(str,"f:\" & files)          '批处理文件生成函数
	Response.write "总共" & cstr(i) & "个"
	end if
	set fso = nothing
	
end if

sub makebat(str,files)

	Set fso1=Server.CreateObject("Scripting.FileSystemObject")
	set objFile = fso1.CreateTextFile(files,True)
	objFile.write str
	objFile.close
	set objFile=nothing
	set fso1 = nothing
	response.write "success!!"             '处理完成，运行生成出来的批处理文件就行了

end sub

%><form method="POST" action="?action=make">
	<p align="center">　</p>
	<p align="center">文件批量操作，</p>
	<p align="center">开始ID<input type="text" name="startid" size="20">&nbsp;&nbsp;&nbsp;&nbsp; 
	结束ID<input type="text" name="endid" size="20"></p>
	<p align="center">要处理的目录：<input type="text" name="folders" size="20"></p>
	<p align="center">要存储的文件名：<input type="text" name="files" size="20"></p>
	<p align="center"><input type="submit" value="生成批处理文件" name="B1"></p>
</form>

