显示文件夹的树形目录

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

'
'	IndexScripts()
'
'
'	Written by Keep Bertha Surfin Heavy Industries,
'	a division of Keep Bertha Surfin Electrical Concern
'	Version 1.0 - KeepBerthaSurfin@Hotmail.com
'

' First thing, check the argument list for a directory.
' If they didn't specify one, use the current directory.

option explicit

' Run the function :)
call IndexScripts


sub IndexScripts()

	dim fso
	set fso = createobject("scripting.filesystemobject")

	dim loc
	if WScript.Arguments.Count = 0 then
		loc = fso.GetAbsolutePathName(".")
	else
		loc = WScript.Arguments(0)
	end if

	GetWorkingFolder loc, 0, 1, "|"

	set fso = nothing
	
End Sub


' called recursively to get a folder to work in
function GetWorkingFolder(foldspec, foldcount, firsttime, spacer)

	dim fso
	Set fso = CreateObject("Scripting.FileSystemObject")

	dim fold
	set fold = fso.GetFolder(foldspec)
	
	dim foldcol
	set foldcol = fold.SubFolders
	
	if firsttime = 1 then
		wscript.echo fold.name
		spacer = ""
		foldcount = foldcol.count
		firsttime = 0
	end if
	
	dim remaincount
	remaincount = foldcol.count
	
	dim sf
	for each sf in foldcol
				
		spacer = spacer + space(3) + "|"
		
		wscript.echo spacer + "-- " + sf.name 
		
		' If you wanted to show the number of bytes, use this line instead of above
		'wscript.echo spacer + "-- " + sf.name + " (uses " + cstr(FormatNumber(sf.size)) + " bytes)"

		if remaincount = 1 then
			spacer = left(spacer, len(spacer) - 1)
			spacer = spacer + " "
		end if
		
		'
		' if you want to do something more useful, put that function call, or just
		' insert the code, here.
		'
		
		remaincount = GetWorkingFolder (foldspec +"\"+sf.name, remaincount, firsttime, spacer)
	
	next 
		
	if len(spacer) > 3 then
		spacer = left(spacer, len(spacer) - 4)
	end if
	
	set fso = nothing
	
	GetWorkingFolder = foldcount - 1

end function