- <!--#include file="Sql_Conn.asp"--><!--#include file="Inc/Inc.asp"--><!--#include file="Inc/Config.asp"-->
- <%
- '本版本为OK版1.0 add by ym on 2008.11.17
- function GetExtendName(FileName)
- dim ExtName
- ExtName = LCase(FileName)
- ExtName = right(ExtName,3)
- ExtName = right(ExtName,3-Instr(ExtName,"."))
- GetExtendName = ExtName
- end function
- '便历某路径下文件夹,把所有MP3数据读到数据库
- function bianli(path)
- dim fso 'fso对象
- dim objFolder '文件夹对象
- dim objSubFolders '子文件夹集合
- dim objSubFolder '子文件夹对象
- dim objFiles '文件集合
- dim objFile '文件对象
- set fso=server.CreateObject("scripting.filesystemobject")
- on error resume next
- set objFolder=fso.GetFolder(path)'创建文件夹对象
- set objSubFolders=objFolder.Subfolders'创建的子文件夹对象
- for each objSubFolder in objSubFolders
- 'nowpath=path + "//" + objSubFolder.name
- nowpath=path + objSubFolder.name
- ' Response.Write nowpath
- set objFiles=objSubFolder.Files
- for each objFile in objFiles
- if GetExtendName(objFile.name) = "mp3" then
- Response.Write "<br>"
- 'Response.Write objFile.name
- dim lc_lj
- lc_lj = nowpath + "/" +objFile.name
- lc_lj=Mid(lc_lj,4) ' 由lc_lj的第4个字符读起,读取后面的所有字符。
- lc_lj=Replace(lc_lj,"/","/")
- 'response.Write(lc_lj)
- dim lc_now
- lc_now = now()
- response.write lc_now
- dim sql_in
- 'sql_in = "insert into ylmv_dj(djCat_Id,specialid,Dj_name,Hits,dj_url,path,dj_pic,dj_user,tjuser,dj_word,dj_desc,IsBest,istop,grade,DownHits,BoxHits,uHits,dHits,DayHits,WeekHits,MonthHits,error,passed,points,music,dj_date,lasthittime) values(11,0,'"+ objFile.name +"',0,'"+ lc_lj +"',5,'rm','紫龙舞曲管理','admin','"+ objFile.name +"','☆☆★★★',1,1,1,0,0,0,0,0,0,0,0,0,0,0,'"+lc_now +"','"+lc_now+"')"
- sql_in1 = "insert into ylmv_dj(djCat_Id,specialid,Dj_name,Hits,dj_url,path,dj_pic,dj_user,tjuser,dj_word,dj_desc,IsBest,istop,grade,DownHits,BoxHits,uHits,dHits,DayHits,WeekHits,MonthHits,error,passed,points,music,deleted) values(11,0,'"+ objFile.name +"',0,'"+ lc_lj +"',5,'rm','紫龙舞曲管理','admin','"+ objFile.name +"','☆☆★★★',1,1,1,0,0,0,0,0,0,0,0,0,0,0,0)"
- 'Response.Write objFile.name
- 'response.Write sql_in1
- conn.execute(sql_in1)
- Response.Write "<br>"
- response.Write("添加"+objFile.name+"!!!!!!")
- end if
- next
- Response.Write "<p>"
- bianli(nowpath) '调用递归
- next
- set objFolder=nothing
- set objSubFolders=nothing
- set fso=nothing
- end function
- %>
- <%
- bianli("F:/Music/") '调用bianli()函数,这里是遍历F:盘
- %>
便历某路径下文件夹,把所有MP3数据读到数据库
本文转载:CSDN博客