By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,670 Members | 1,563 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,670 IT Pros & Developers. It's quick & easy.

How can I concatenate several text files into a single file?

P: n/a
I need to concatenate serveral text files into a larger file.

I borrowed some code and patched together a batch file that runs in the
command processor and looks like this:

echo off
chdir C:\Documents and Settings\dave\My Documents\SQL\Deploy

rem Create tables
echo Generate CREATE TABLE SQL script [CreateTables.sql] ...

echo PRINT ' Create tables ...' > CreateTables.sql

cat ./Tables/dbo.table1.tab ./Tables/dbo.table2.tab ./Tables/dbo.table3.tab
CreateTables.sql


But it fails with the command "cat" ("'cat' is not recognized as an internal
or external command, operable program or batch file").

Can anyone tell me how I can concatenate my files?
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Dave,

Programatically, I would just create a new FileStream instance that
represents the new file. Then, I would open up the other files
sequentially, reading the contents from those, and writing the contents to
the new file.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dave" <da**@nospam.ru> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I need to concatenate serveral text files into a larger file.

I borrowed some code and patched together a batch file that runs in the
command processor and looks like this:

echo off
chdir C:\Documents and Settings\dave\My Documents\SQL\Deploy

rem Create tables
echo Generate CREATE TABLE SQL script [CreateTables.sql] ...

echo PRINT ' Create tables ...' > CreateTables.sql

cat ./Tables/dbo.table1.tab ./Tables/dbo.table2.tab
./Tables/dbo.table3.tab
CreateTables.sql


But it fails with the command "cat" ("'cat' is not recognized as an
internal
or external command, operable program or batch file").

Can anyone tell me how I can concatenate my files?

Nov 16 '05 #2

P: n/a
In C# ??
"Dave" <da**@nospam.ru> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
I need to concatenate serveral text files into a larger file.

I borrowed some code and patched together a batch file that runs in the
command processor and looks like this:

echo off
chdir C:\Documents and Settings\dave\My Documents\SQL\Deploy

rem Create tables
echo Generate CREATE TABLE SQL script [CreateTables.sql] ...

echo PRINT ' Create tables ...' > CreateTables.sql

cat ./Tables/dbo.table1.tab ./Tables/dbo.table2.tab
./Tables/dbo.table3.tab
CreateTables.sql


But it fails with the command "cat" ("'cat' is not recognized as an
internal
or external command, operable program or batch file").

Can anyone tell me how I can concatenate my files?

Nov 16 '05 #3

P: n/a
If the file size is within gigabytes, use the DOS's "COPY" command:
copy file1+file2+file3 destinationfile.

It seems that I post the answer in the wrong group. :~)
"Dave" <da**@nospam.ru> glsD:%2***************@TK2MSFTNGP15.phx. gbl...
I need to concatenate serveral text files into a larger file.

I borrowed some code and patched together a batch file that runs in the
command processor and looks like this:

echo off
chdir C:\Documents and Settings\dave\My Documents\SQL\Deploy

rem Create tables
echo Generate CREATE TABLE SQL script [CreateTables.sql] ...

echo PRINT ' Create tables ...' > CreateTables.sql

cat ./Tables/dbo.table1.tab ./Tables/dbo.table2.tab
./Tables/dbo.table3.tab
CreateTables.sql


But it fails with the command "cat" ("'cat' is not recognized as an
internal
or external command, operable program or batch file").

Can anyone tell me how I can concatenate my files?

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.