Posts Tagged ‘vbs’

Recursively iterate through every file/subfolder – VBScript

Tuesday, December 30th, 2008

This is actually a lot simpler than I expected (gimme a break, this is my second foray into VBS!)

Set fs = WScript.CreateObject ("Scripting.FileSystemObject")

Sub ShowSubFolders(Folder)
	For Each Subfolder In Folder.SubFolders
		Set files = SubFolder.Files
		For Each file In files
			WScript.Echo file.Name, file.Size
		Next
		ShowSubFolders Subfolder
	Next
End Sub

ShowSubFolders fs.GetFolder("C:\your\path\here")