This is definitely my most used VBScript function ever. Just specify a directory a you’ll receive a complete directory listing recursively.
' ##################################################################### ' ## ' ## (C) 2005 Michael Miklis (michaelmiklis.de) ' ## ' ## ' ## Filename: ListFilesRecursive.vbs ' ## ' ## Version: 1.0 ' ## ' ## Release: Final ' ## ' ## Requirements: -none- ' ## ' ## Description: Creates a List of files and folders ' ## ' ## This script is provided 'AS-IS'. The author does not provide ' ## any guarantee or warranty, stated or implied. Use at your own ' ## risk. You are free to reproduce, copy & modify the code, but ' ## please give the author credit. ' ## ' #################################################################### Option Explicit Dim objFS Set objFS = CreateObject ("Scripting.FileSystemObject") wscript.echo CreateFileList(objFS.GetFolder("C:\Users\michael\desktop"), True) Set objFS = Nothing '______________________FUNCTIONS & SUB ROUTINES_______________________ Function CreateFileList(objFolder, bRecursive) '// <summary> '// Creates a List containing all Files '// </summary> '// <param name="objFolder">Root-Folder for searching</param> '// <param name="bRecursive">Search recursive</param> Dim objFile, objSubFolder For each objFile in objFolder.Files CreateFileList = CreateFileList & objFile.Path & vbCr Next If bRecursive = true then For each objSubFolder in objFolder.Subfolders CreateFileList = CreateFileList & CreateFileList(objSubFolder, true) Next End If End Function