Demonstration script that uses VBScript’s RegExp object to list the names of files within a directory which match a given regular expression. You must provide the script with a single command line parameter: the regular expression to match against.

Visual Basic
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
strCurrentDirectory = objShell.CurrentDirectory

Set objFolder = objFS.GetFolder(strCurrentDirectory)
Set colFiles = objFolder.Files

Set objRE = New RegExp
objRE.Global     = True
objRE.IgnoreCase = False
objRE.Pattern    = WScript.Arguments(0)

For Each objFile In colFiles
   bMatch = objRE.Test(objFile.Name)
   If bMatch Then
      WScript.Echo objFile.Name
   End If