Can someone post an example of how I can merge (append) a list of text
files (all in same directory) into one big text file? This would be
easy in unix shell scripting, but I cant figure it out with vbscript.
If it cant be done, I would take a DOS solution if someone knows how.
-thanks!

Re: example of how to append all txt files in a directory into one file by Fabrice

Fabrice
Tue Apr 05 11:53:45 CDT 2005

Hi,



The easiest way



Copy *.txt new newfile.txt



However you can have issue with CR at the end of the file and concatenate
without a new line.

Assuming that you have only text file in your directory...



Set fso = CreateObject("Scripting.FileSystemObject")
set mainfolder=fso.GetFolder(".")
Set filecollection = mainfolder.Files



Set objfileOut=fso.OpenTextFile ("fileout.txt",2,true)
init=false


For Each fileList In filecollection
Set objfileRead=fso.OpenTextFile(fileList.Name,1,false)
do while not objfileRead.AtEndOfStream
s=objfileRead.readline()
objfileOut.WriteLine s
loop
objfileRead.CLose()
Next
response.write "Done!"



You may have to change encoding, folder, and test for file extension
depending on your configuration.



Thanks,
Fabrice Canel

<emebohw2@netscape.net> wrote in message
news:1112718162.375015.326650@l41g2000cwc.googlegroups.com...
> Can someone post an example of how I can merge (append) a list of text
> files (all in same directory) into one big text file? This would be
> easy in unix shell scripting, but I cant figure it out with vbscript.
> If it cant be done, I would take a DOS solution if someone knows how.
> -thanks!
>



Re: example of how to append all txt files in a directory into one file by Gabriel

Gabriel
Tue Apr 05 11:34:20 CDT 2005

I think, the best way to do that its doing the next:

1) use the "shell" method to execute a command line COPY

shell "COPY *.txt NameofyourBIGFILE.txt /A"

/B = indicates a binary copy
/A = ASCII text file copy

Good luck,

Gabriel.


<emebohw2@netscape.net> wrote in message
news:1112718162.375015.326650@l41g2000cwc.googlegroups.com...
> Can someone post an example of how I can merge (append) a list of text
> files (all in same directory) into one big text file? This would be
> easy in unix shell scripting, but I cant figure it out with vbscript.
> If it cant be done, I would take a DOS solution if someone knows how.
> -thanks!
>



Re: example of how to append all txt files in a directory into one file by Jerold

Jerold
Tue Apr 05 12:36:49 CDT 2005

On 5 Apr 2005 09:22:42 -0700, emebohw2@netscape.net wrote:

>Can someone post an example of how I can merge (append) a list of text
>files (all in same directory) into one big text file? This would be
>easy in unix shell scripting, but I cant figure it out with vbscript.
>If it cant be done, I would take a DOS solution if someone knows how.
>-thanks!

Using a bat file, to merge all the .txt files in c:\folder into big.txt, and delete the merged files:

@echo off
setlocal ENABLEDELAYEDEXPANSION
pushd c:\Folder
for /f "Tokens=*" %%a in ('dir /a /b /a-d *.txt') do (
if defined bigc set bigc=!bigc!+
set bigc=!bigc!"%%a"
if defined bigd set bigd=!bigd!^&
set bigd=!bigd!del /q "%%a"
)
copy %bigc% big.txt
%bigd%
popd
endlocal

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com

Re: example of how to append all txt files in a directory into one by ews

ews
Tue Apr 05 18:13:06 CDT 2005

how bout the trusty type command

type *txtfiles* >> bigfile.txt

much like our unix friend cat =)

emebohw2@netscape.net wrote:
> Can someone post an example of how I can merge (append) a list of text
> files (all in same directory) into one big text file? This would be
> easy in unix shell scripting, but I cant figure it out with vbscript.
> If it cant be done, I would take a DOS solution if someone knows how.
> -thanks!
>