日期:2014-05-16  浏览次数:20817 次

asp实现批量建立目录
    求实现  目录生成 
  目录是3个字符组成、
分别是 1-9 a-z
    如何批量生成这样的目录。

------解决方案--------------------
s=""
for i=49 to 57'1~9
  s=s&chr(i)
next
for i=97 to 122'a~z
  s=s&chr(i)
next
sLen=len(s)

Function rndint(byval MinNum,byval MaxNum)'asp生成整数之间的随机数函数
  dim tmp
  if MaxNum<MinNum then'交换大小值,防止传递时大小搞反
    tmp=MinNum:MinNum=MaxNum:MaxNum=tmp
  end if
  
  Randomize
  rndint=int(rnd *(MaxNum-MinNum+1)+MinNum)
End Function

Function GetFolderName()
  fd="":irnd=0
  for j=1 to 3
    irnd=rndint(1,sLen)
    fd=fd&mid(s,irnd,1)
  next
  GetFolderName=fd
end Function

set fso=server.createobject("scripting.filesystemobject")
for i=1 to 10'想建立多少个修改这里
  p=Server.MapPath(GetFolderName())
  response.Write p&"<br/>"
  if not fso.FolderExists(p) then
    fso.createfolder(p)
    response.Write p&"创建成功<br/>"
  end if
next
set fso=nothing

------解决方案--------------------
Dim code,i,ii,iii,l,temp,temp2,fso,truepath
code="0123456789qwertyuiopasdfghjklzxcvbnm"
l=Len(code)
Set fso=server.createobject("scripting.filesystemobject")
For i=1 To l
temp=Mid(code,i,1)
For ii=1 To l
temp2=temp&Mid(code,ii,1)
For iii=1 To l
truepath=server.mappath("\www\"&temp2&Mid(code,iii,1)&"\")
If fso.folderexists(truepath)=False Then fso.createfolder(truepath)
Next
Next
Next
Set fso=Nothing

经测试可以生成,但因文件夹太多会超时,建议分开几次生成。