Write all the file names in a folder to a log file and append "END" statement

  • Hi ,

    I am using DTS to create files and dump into a folder and at a same time I need to use Active X VBS to create a log file and write down the file names that I created and at the end of the file name I need to append a "END" statement on the log file. If there are no files created on the that folder durinf the DTS run I need to create a log file with just an "END" statement as well. Below is my example. Please advise. Thanks.

    logfile that has 3 files during the DTS run

    ___________________

    abc_200905180411.csv

    abc_200905180412.csv

    abc_200905180413.csv

    END

    logfile that has no files during the DTS run

    ____________________________________

    END

  • How much of this are you able to do currently? Which bits do you require assistance with?

  • Hi

    I have fixed the problem. I am good to go . Below is the solution. Thanks.

    Set FSO = CreateObject("Scripting.FileSystemObject")

    Set objDirectory = FSO.GetFolder(strPath)

    Set final = objFSO.CreateTextFile(strLog, 2)

    For Each objFile In objDirectory.Files

    ''Set path and file names

    strFileName = objFile.Name

    If Not (strFile= "") Then

    If strFileName DTSGlobalVariables("strLogName").Value Then

    final.WriteLine (strFile)

    End if

    End If

    Next

    final.WriteLine ("END")

    final.Close

    Set objFSO = Nothing

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply