Can someone tell me this sample script out of the Microsoft Press book
by Ed Wilson won't run properly?
When I run it is displays every file in the folder, the same number of
times that there are files in the folder....
IE...if there are nine files in the folder it shows all nine files nine
times with a different file size for each one. Any help would be
appreciated.
Thanks:
'===================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies
PrimalSCRIPT(TM)
'
' NAME: <filename>
'
' AUTHOR: ed wilson , mred
' DATE : 9/21/2003
'
' COMMENT: <comment>
'
'===================================================================
Option Explicit
Dim objDictionary
Dim objFSO
Dim objFolder
Dim colFiles
Dim objFile
Dim colItems
Dim colKeys
Dim strKey
Dim strItem
Set objDictionary = CreateObject("scripting.dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\scriptingBook")
Set colFiles = objFolder.Files
For Each objFile In colFiles
objDictionary.Add objFile.Name, objFile.Size
Next
colItems = objDictionary.Items
colKeys = objDictionary.Keys
For Each strKey In colKeys
For Each strItem In colItems
WScript.Echo "filename: " & strKey & " size: " & strItem
Next
Next
WScript.Echo "***there are " & objDictionary.Count & " files"