Consolidate multiple files

  • Hey does any one know the best way to consolidate multiple files for single dts processing ??

  • Ahhh ... just guessing here ... but you'd probably need to provide a bit more detail about your situation before you'll get a useful answer.

    I could say that you can issue the DOS Copy command (eg: Copy file1 + file2 File3 /b), but that might not be appropriate in you're situation. Another method would be to use VBScript. Open one file for appending, read in the second file and write it to the first file. Works well for small files but takes forever to process large multi-megabyte files.

     

    --------------------
    Colt 45 - the original point and click interface

  • Hey yes sorry i will in the future but yes i was thinking in the same lines as you the command am working on is

    copy c:\temp\te*.txt = c:\temp\temp.txt

    Which copies all the files starting with "te" and that are .txt and add them into a destination file called temp.txt

    The command i found was copy file1 + file2 = file3

    this will put the contents of file 1 + file 2 into file3

     

    thanks for ur help.

  • for %I in (te*.txt) do type %I >> newfile.txt

    wha-bam.

    jg

  • This is a nice .vbs that I use:

    ____________________________________________________________________________________

    Const OpenAsASCII      =  0

    Const OverwriteIfExist = -1

    Set oFSO = CreateObject("Scripting.FileSystemObject")

    sResultFile = "e:\merge.txt"  ' any existing file will be overwritten!

    sSourceFolder = "e:\test"

    Set oFolder = oFSO.GetFolder(sSourceFolder)

    Set fRF = oFSO.CreateTextFile(sResultFile, OverwriteIfExist, OpenAsASCII)

    fRF.Close

    sRFShort = oFSO.GetFile(sResultFile).ShortPath

    sCopyLine = sRFShort

    For Each oFile In oFolder.Files

    sCopyLine = sCopyLine & "+" & oFile.ShortPath

    ' check length so the command line doesn't get too long

    If Len(sCopyLine) > 900 Then

    MergeFiles sRFShort, sCopyLine

    sCopyLine = sRFShort

    End If

    Next

    ' handle any copy line less than 900 characters

    If sCopyLine <> sRFShort Then

    MergeFiles sRFShort, sCopyLine

    End If

    Sub MergeFiles(sTargetFile, sFilesToCopy)

    Set oShell = CreateObject("WScript.Shell")

    sCmd = "%comspec% /c copy /b /y " & sFilesToCopy & " " & sTargetFile

    iRC = oShell.Run(sCmd, 0, True)

    If iRC <> 0 Then

    WScript.Echo "Copy operation failed, aborting!"

    WScript.Quit

    End If

    End Sub

    ____________________________________________________________________________________

Viewing 5 posts - 1 through 4 (of 4 total)

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