John Topley's Knowledgebase

Creating A List Of Files Of A Certain Type

Friday, 30 May 2003

This Windows Script Host script creates a text file listing the names of all of the files that match a file specification within a specified folder.

Download CreateFileList.vbs

' Script to create a text file listing all of the files matching
' a file specification within a folder.
' This example lists all DLLs in the system32 folder.
Option Explicit
Private fsoFile
Private fsoFileSystem
Private txsTextStream
Private wshShell

Set fsoFileSystem = CreateObject("Scripting.FileSystemObject")
Set txsTextStream = fsoFileSystem.CreateTextFile("File List.txt", True)
Set wshShell = WScript.CreateObject("WScript.Shell")

For Each fsoFile In fsoFileSystem.GetFolder(wshShell.ExpandEnvironmentStrings("%SYSTEMROOT%\system32")).Files
  If fsoFile.Type = "Application Extension" Then
    txsTextStream.WriteLine (fsoFile.Path)
  End If
Next

WScript.Echo "Successfully created File List.txt."

Set wshShell = Nothing
Set txsTextStream = Nothing
Set fsoFileSystem = Nothing

top | index | previous | next | comments ()

home | archive | kb | media | about | contact | accessibility
Copyright © 2003 - 2005 John Topley. Made with CityDesk.