Software >> OS >> Windows >> Scripting >> VBScript >>  How to loop through files in a directory

sDir = "c:\winnt" Set fso = Wscript.CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(sDir) Set fc = f.Files iCount = 0 For Each f1 in fc iCount = iCount 1 sFile = f1.name wscript.echo sFile Next