首页 > 数据库 >便历某路径下文件夹,把所有MP3数据读到数据库

便历某路径下文件夹,把所有MP3数据读到数据库

时间:2022-12-13 12:33:27浏览次数:45  
标签:dim dj name lj 文件夹 MP3 objFile 便历 lc

<!--#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 '文件对象

fso=server.CreateObject("scripting.filesystemobject")
on error resume next
objFolder=fso.GetFolder(path)'创建文件夹对象
objSubFolders=objFolder.Subfolders'创建的子文件夹对象
for each objSubFolder in objSubFolders
nowpath=path + "//" + objSubFolder.name
nowpath=path + objSubFolder.name
' Response.Write nowpath
objFiles=objSubFolder.Files
for each objFile in objFiles
if GetExtendName(objFile.name) = "mp3" then
<br>"
'Response.Write objFile.name

dim lc_lj
lc_lj = nowpath
lc_lj=Mid(lc_lj,4) ' 由lc_lj的第4个字符读起,读取后面的所有字符。
lc_lj=Replace(lc_lj,"/","/")
'response.Write(lc_lj)

dim lc_now
lc_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)
<br>"
response.Write("添加"+objFile.name+"!!!!!!")
end if


next
<p>"
bianli(nowpath) '调用递归
next
objFolder=nothing
objSubFolders=nothing
fso=nothing
end function
%>
<%
bianli("F:/Music/") '调用bianli()函数,这里是遍历F:盘
%>

标签:dim,dj,name,lj,文件夹,MP3,objFile,便历,lc
From: https://blog.51cto.com/u_512327/5933799

相关文章