join txt-files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
didley

join txt-files

#1 Post by didley » 18 Jul 2006 00:18

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?

Helper

#2 Post by Helper » 18 Jul 2006 06:25

Try:

Code: Select all

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

:wink:

didley

#3 Post by didley » 18 Jul 2006 07:46

it is really so simple !

Thanks !!

RDCPro

Or, you can use the >>

#4 Post by RDCPro » 06 Sep 2006 18:22

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

k3lvinmitnick.co.cc
Posts: 6
Joined: 17 Jun 2009 20:17
Location: http://vietdzung.net
Contact:

#5 Post by k3lvinmitnick.co.cc » 17 Jun 2009 22:41

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 ?

RElliott63
Expert
Posts: 80
Joined: 04 Feb 2009 10:03

#6 Post by RElliott63 » 18 Jun 2009 07:50

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!

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

#7 Post by ghostmachine4 » 18 Jun 2009 21:51

does the order of your files matter ??

rfpd
Posts: 78
Joined: 06 Jul 2009 16:19
Location: Lisbon, Portugal
Contact:

hello

#8 Post by rfpd » 06 Jul 2009 16:36

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

Post Reply