Page 1 of 1

join txt-files

Posted: 18 Jul 2006 00:18
by didley
Hi,

I need some help. My problem is how can I join some txt-files in a easy way. For example:

one.txt + two.txt + three.txt. + ... + n.txt == together.txt

Is there a easy way to solve this task with a dos-batch?

Posted: 18 Jul 2006 06:25
by Helper
Try:

Code: Select all

copy one.txt + two.txt + three.txt. + ... + n.txt together.txt 

:wink:

Posted: 18 Jul 2006 07:46
by didley
it is really so simple !

Thanks !!

Or, you can use the >>

Posted: 06 Sep 2006 18:22
by RDCPro
You can use the Type command, and append the output to a text file, like:

REM Create a new output.txt file, with the contents of file0.txt
Type File0.txt > output.txt
REM Append the contents of File1.txt to output.txt
Type File1.txt >> output.txt
REM Append the contents of File2.txt to output.txt
Type File2.txt >> output.txt

I use this to write a log of the progress of the batch file. For example, any output from osql.exe goes to a temp file, which is then appended to output.txt. When I'm done, I delete the temp file:

TYPE JobHeader.txt > output.txt
TYPE JobSeparator.txt >> output.txt

ECHO running Test.sql...
ECHO osql -E -S %server_name% -d %database% -o out.txt -i "Test.sql"
osql -E -S %server_name% -d %database% -o out.txt -i "Test.sql"

TYPE out.txt >> output.txt
TYPE JobSeparator.txt >> output.txt

ECHO running Test2.sql...
ECHO osql -E -S %server_name% -d %database% -o out.txt -i "Test2.sql"
osql -E -S %server_name% -d %database% -o out.txt -i "Test2.sql"

TYPE out.txt >> output.txt
TYPE JobSeparator.txt >> output.txt

DEL out.txt

Regards,
Mike Sharp

Posted: 17 Jun 2009 22:41
by k3lvinmitnick.co.cc
Helper wrote:Try:

Code: Select all

copy one.txt + two.txt + three.txt. + ... + n.txt together.txt 

:wink:


Code for multi files ? Because i need join for 1000 files, i must type 1000 times ?

Posted: 18 Jun 2009 07:50
by RElliott63
Assuming all the files you need to concatenate are in the same folder:

Code: Select all

Set "Out=\Temp\Outfile.txt"
Echo > %Out%

For /F %%F in ( 'Dir /B Folder\Name*.ext' ) Do (
     Copy %Out% + %%F %Out%
)


Or, you could type it 1000 times ... it's your choice!

Posted: 18 Jun 2009 21:51
by ghostmachine4
does the order of your files matter ??

hello

Posted: 06 Jul 2009 16:36
by rfpd
hello i am a portugese boy with 13 years old exactly i am here to help you.

Image

first we have a image saying ola is the first text

Image

then the second text

Image

and finaly the third text

now let's go for the code

Code: Select all

copy /b 1.txt + 2.txt + 3.txt = final.txt


this is just examples you can put only 1.txt + 2.txt or another name but first you put cd Desktop and you create in the desktopfor beeing more easy to locate the files.

and the result is:

Image