本帖最后由 jyswjjgdwtdtj 于 2023-3-1 17:36 编辑
回复 1# amio555
稍微改一下
用的是ul,li
可以无限多嵌套子文件夹- set document= createobject("htmlfile")
- set fso= createobject("scripting.filesystemobject")
- foldername=inputbox("文件夹地址")
- set nowfolder=fso.getfolder(foldername)
- document.write "<html><head></head><body>"&vbcrlf&_
- "<a href="&nowfolder.path&">"&nowfolder.name&"</a>"&vbcrlf&_
- "<ul id=filetree></ul></body></html>"
- set filetreeul=document.getelementbyid("filetree")
- filetree nowfolder,filetreeul
- sub filetree(fdobject,nowelement)
- set files=fdobject.files
- set folders=fdobject.subfolders
- for each file in files
- set newli=document.createelement("LI")
- set newa=document.createelement("A")
- newa.href=file.path
- newa.classname="File"
- newa.innertext=fso.getfilename(file.path)
- newli.appendchild(newa)
- nowelement.appendchild(newli)
- next
- for each folder in folders
- set newli=document.createelement("LI")
- set newa=document.createelement("A")
- newa.href=folder.path
- newa.innertext=folder.name
- newa.classname="Folder"
- newli.appendchild(newa)
- set newul=document.createelement("UL")
- filetree folder,newul
- newli.appendchild(newul)
- nowelement.appendchild(newli)
- next
- end sub
- set f=fso.createtextfile("filetree.html",true,true)
- f.writeline "<html>"&vbcrlf&document.getelementsbytagname("html")(0).innerhtml&vbcrlf&"</html>"
- f.close
复制代码 生成如下- <html>
- <HEAD></HEAD>
- <BODY><A href="C:\Users\admin\Documents\mine Files>mine Files</A>
- <UL id=filetree>
- <LI><A href="C:\Users\admin\Documents\mine Files\demon.tw包含下载用vbs.zip">demon.tw包含下载用vbs.zip</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\《全职剑修》.txt">《全职剑修》.txt</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\《我在诸天轮回封神》.txt">《我在诸天轮回封神》.txt</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\《我的属性修行人生》.txt">《我的属性修行人生》.txt</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\《神权之上》.txt">《神权之上》.txt</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\《这游戏也太真实了》.txt">《这游戏也太真实了》.txt</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\《青莲之巅》.txt">《青莲之巅》.txt</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\新建文本文档.bat">新建文本文档.bat</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\Audio&Video">Audio&Video</A>
- <UL></UL></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\mine">mine</A>
- <UL></UL></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\Files">Files</A>
- <UL>
- <LI><A href="C:\Users\admin\Documents\mine Files\Files\filetree.html">filetree.html</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\Files\新建文本文档.html">新建文本文档.html</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\Files\新建文本文档.vbs">新建文本文档.vbs</A></LI></UL></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\新建文件夹">新建文件夹</A>
- <UL>
- <LI><A href="C:\Users\admin\Documents\mine Files\新建文件夹\1.bat">1.bat</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\新建文件夹\1.bmp">1.bmp</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\新建文件夹\1.ps1">1.ps1</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\新建文件夹\1.vbs">1.vbs</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\新建文件夹\b.vbs">b.vbs</A></LI>
- <LI><A href="C:\Users\admin\Documents\mine Files\新建文件夹\新建文本文档.bat">新建文本文档.bat</A></LI></UL></LI></UL></BODY>
- </html>
复制代码
|