Submitted By: Anonymous Submission

This scripts allows you to retrieve the file names within a specified folder. I use this with an automated FTP task and DTS to generate parameter files dynamically.

Visual Basic
Edit|Remove
Option Explicit

DIM oFSO
DIM oFile
DIM oCreateStream
DIM oAppendStream
DIM oFolder
DIM strScriptResults 

CONST    intTriStateFalse = 0
CONST    intForAppending = 8

strScriptResults = "C:\Scripts\ScriptResults.txt"

SET     oFSO = CREATEOBJECT("Scripting.FileSystemObject")
SET    oFolder = oFSO.GETFOLDER("C:\Scripts\")
SET    oCreateStream = oFSO.CreateTextFile(strScriptResults, True, intTriStateFalse)

oCreateStream.Close

FOR EACH oFile IN oFolder.Files
    
    SET oAppendStream = oFSO.OpenTextFile(strScriptResults, intForAppending, False, intTriStateFalse)
    WITH oAppendStream
        .WriteLine oFile.Name
        .Close
    END WITH
    
NEXT

SET oFSO = NOTHING
SET oCreateStream = NOTHING
SET oAppendStream = NOTHING
SET oFolder = NOTHING