VBS递归遍历文件夹

'WalkFolders.vbs
't0nsha<liaodunxia#gmail.com>
'2010/3/20

'得到脚本文件所在的当前目录
Function GetCurrentFolderFullPath
	Set fso = CreateObject("Scripting.FileSystemObject")
	GetCurrentFolderFullPath = fso.GetParentFolderName(WScript.ScriptFullName)
End Function

'vbs递归遍历当前目录下的所有文件夹和子文件夹
Function GetSubFolders(currentFolderFullPath)
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set currentFolder = fso.GetFolder(currentFolderFullPath)
	Set subFolderSet = currentFolder.SubFolders
	For Each subFolder in subFolderSet
		'MsgBox "subFolder.Path=" & subFolder.Path
		GetSubFolders = subFolder.Path & ";" & GetSubFolders(subFolder.Path) &  GetSubFolders 
	Next
End Function

MsgBox GetSubFolders(GetCurrentFolderFullPath)


原文链接: http://blog.csdn.net/t0nsha/article/details/5398272

你可能感兴趣的:(VBS递归遍历文件夹)