Sunday, April 25, 2010

How to display all the files in a Folder in VB Script

Write a script in VB to display all the files in a Folder using FileSystemObject

The VB Script to display all the files of a Folder uses the GetFolder and Files method to print all the files.


'Step 1: Create and object variable to interact with the File system object
Set fso=createobject("Scripting.FileSystemObject")

'Step 2: Point to the folder from which we want to print the file names
Set fol = fso.GetFolder("F:\YouTube Downloader")

'Step 3: Return all the files collection from the specified folder
Set fil = fol.files

'Print all the file names from the specified folder
For each f in fil
str = str&" "&f.name&", "
Next

Msgbox The files in the Folder YouTube Downloader are " &Vbnewline&str

No comments:

Post a Comment