Results 1 to 2 of 2

Thread: appending files

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    1
    Hi,

    I would like to append several postscript files in a folder to one temporary file in the same folder. I have been able to do it using a batch file as shown below:

    REM !Merge all ps files (*.ps) to one

    FOR %%i IN (C:\postscript\*.ps) DO (type %%i >> C:\postscript\postscript.tmp)

    But I would like to be able to do this in VB. Can this be done using FileSystemObject? I have never used FileSystemObject since I am fairly new to VB so I would appreciate any help.

  2. #2
    Lively Member
    Join Date
    Mar 2000
    Posts
    82
    i am also new to vb, but i hope i can at least send you down the right track...

    this will copy all my files with the .txt ext in c:\ to one file called allfiles.txt. hope it helps!

    Dim fso As New FileSystemObject
    Dim f As Scripting.File
    Dim destF As Scripting.TextStream
    Dim sourceF As Scripting.TextStream
    Set destF = fso.CreateTextFile("c:\allfiles.txt")

    Dim temp As String
    For Each f In fso.GetFolder("c:\").Files
    If UCase(Right$(f, 3)) = "TXT" Then
    Set sourceF = f.OpenAsTextStream
    temp = sourceF.ReadAll
    destF.WriteLine (temp)
    End If
    Next

    there is likely an easier way to do this
    good luck.

    [Edited by _bman_ on 03-19-2000 at 04:23 PM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width