[vbs] Get folder names / file names in a directory

18 February, 2011 at 5:46 pm Leave a comment

‘Option explicit

Set fs = CreateObject(“Scripting.FileSystemObject”)

‘create output file
Set outFile = fs.CreateTextFile(“d:\folder_name.txt”)

‘set directory
Set oFolder = fs.GetFolder(“d:\”)

‘if get file name use this
‘Set oFiles = oFolder.Files

‘if get folder name use this
Set oSubFolder = oFolder.SubFolders

‘go through list
For Each i In oSubFolder

‘write to output
outFile.writeline i.Name

Next

WScript.Echo “Finish!”

Entry filed under: IT/Soft.

V-day linked-in

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


February 2011
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28  

%d bloggers like this: