DTS - text file as source

  •  

    i am using a text file as the source for uploading a table using DTS.

    The requirement is that in a directory there will be number of text files.These text files needs to be contenated into a single text file which should be used as the source. Can this be done with VB script? Please help.

    Thanks & Regards,

    Vidya

  • You most definently do so using filessystemobjects and file object to open, read and save.

    Simple example

    Dim x, z, objText, objText1, objText2, objText3, objText4

    set x = CreateObject("Scripting.FileSystemObject")

    set objText = x.OpenTextFile("C:\Incoming\ExtractComplex.txt",8,true)

     

    set objText1 = x.OpenTextFile("C:\Incoming\ExtractComplexPart1.txt",1)

    z = objText1.ReadAll

    objText.Write(z)

    set objText2 = x.OpenTextFile("C:\Incoming\ExtractComplexPart2.txt",1)

    z = objText2.ReadAll

    objText.Write(z)

    set objText3 = x.OpenTextFile("C:\Incoming\ExtractComplexPart3.txt",1)

    z = objText3.ReadAll

    objText.Write(z)

    set objText4 = x.OpenTextFile("C:\Incoming\ExtractComplexPart4.txt",1)

    z = objText4.ReadAll

    objText.Write(z)

    objText.Close

    objText1.Close

    objText2.Close

    objText3.Close

    objText4.Close

    Set objText = nothing

    Set objText1 = nothing

    Set objText2 = nothing

    Set objText3 = nothing

    Set objText4 = nothing

    But in this case I know all the files if you don't you can of course read them and cycle thru using the GetFolder method and enumerate the files in it.

    Also, if all your files have the same basic name such as my example you can even use the DOS Copy command like so.

    Copy "C:\Incoming\ExtractComplexPart*.txt" /B "C:\Incoming\ExtractComplex.txt" /B

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

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