gives an example on reading a directory. I added the array part of it and commented
out the write part of it.
I write in vb but I’m not an expert in it so no promises. I prefer perl.
I’m sure somebody else will chime in with another example.
Here’s the code I ended up with, it works on my win7 machine.
cscript listdir.vbs c:\junk
On Error Resume Next
Dim fso, folder, files, NewsFile,sFolder
Dim myarray(50), count, count2
Set fso = CreateObject(“Scripting.FileSystemObject”)
sFolder = Wscript.Arguments.Item(0)
If sFolder = “” Then
Wscript.Echo “No Folder parameter was passed”
‘ Set NewFile = fso.CreateTextFile(sFolder&”\FileList.txt”, True)
Set folder = fso.GetFolder(sFolder)
Set files = folder.Files
count = 0
For each folderIdx In files
myarray(count) = folderIdx.Name
count = count + 1
For count2 = 0 to count -1
Wscript.Echo myarray(count2) ‘ write out the array