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

  1. <!--#include file="Sql_Conn.asp"--><!--#include file="Inc/Inc.asp"--><!--#include file="Inc/Config.asp"-->
  2. <%
  3. '本版本为OK版1.0  add by ym on 2008.11.17
  4. function GetExtendName(FileName) 
  5. dim ExtName 
  6. ExtName = LCase(FileName) 
  7. ExtName = right(ExtName,3) 
  8. ExtName = right(ExtName,3-Instr(ExtName,".")) 
  9. GetExtendName = ExtName 
  10. end function
  11. '便历某路径下文件夹,把所有MP3数据读到数据库 
  12.     function bianli(path)
  13.         dim fso            'fso对象
  14.         dim objFolder      '文件夹对象
  15.         dim objSubFolders '子文件夹集合
  16.         dim objSubFolder   '子文件夹对象
  17.         dim objFiles       '文件集合
  18.         dim objFile        '文件对象
  19.         set fso=server.CreateObject("scripting.filesystemobject")    
  20.         on error resume next
  21.         set objFolder=fso.GetFolder(path)'创建文件夹对象
  22.         set objSubFolders=objFolder.Subfolders'创建的子文件夹对象
  23.         for each objSubFolder in objSubFolders
  24.             'nowpath=path + "//" + objSubFolder.name
  25.             nowpath=path  + objSubFolder.name
  26.            ' Response.Write nowpath
  27.             set objFiles=objSubFolder.Files
  28.             for each objFile in objFiles
  29.               if GetExtendName(objFile.name)  = "mp3" then
  30.                               Response.Write "<br>"
  31.                 'Response.Write objFile.name
  32.                 
  33.                 dim lc_lj 
  34.                 lc_lj = nowpath + "/" +objFile.name
  35.                 lc_lj=Mid(lc_lj,4)         ' 由lc_lj的第4个字符读起,读取后面的所有字符。
  36.                 lc_lj=Replace(lc_lj,"/","/")
  37.                 'response.Write(lc_lj)
  38.                 
  39.                 dim lc_now
  40.                 lc_now = now()
  41.                 response.write lc_now
  42.                 
  43.                 dim sql_in
  44.                 '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+"')"
  45.                 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)"
  46.                 'Response.Write objFile.name
  47.                 'response.Write sql_in1
  48.                 conn.execute(sql_in1)
  49.                  Response.Write "<br>"
  50.                 response.Write("添加"+objFile.name+"!!!!!!")
  51.               end if
  52.             
  53.             next
  54.             Response.Write "<p>"
  55.             bianli(nowpath)    '调用递归
  56.         next
  57.         set objFolder=nothing
  58.         set objSubFolders=nothing
  59.         set fso=nothing
  60.     end function
  61. %>
  62. <%
  63.     bianli("F:/Music/") '调用bianli()函数,这里是遍历F:盘
  64. %>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

紫气东来_999

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值