1.

Solve : how to combine 2 or more file.txt?

Answer»
i want to combine text in file1.txt with text in file2.txt, combination in new file.txt

so far this is batch i create

Code: [Select]echo off

setlocal disableDelayedExpansion

for /f "delims=" %%A in ('type file1.txt') do call :starter1 "%%A"

:starter1
set "start=%%A"

echo %start%>> "new text.txt"

for /f "delims=" %%A in ('type file2.txt') do call :starter2 "%%A"

:starter2
set "start=%%A"

echo %start%>> "new text.txt"


any suggestion that could make this work?

i just a new guy who still learning from STUFF i try to do...
thank youThe main problem I can see is that once it is done the for loop, it moves onto the function :starter1,
Oh, also you are using the for argument inside the call function... Try this:

Code: [Select]echo.>"new text.txt"
for /f "delims=" %%A in ('type file1.txt') do call :print "%%A"

for /f "delims=" %%A in ('type file2.txt') do call :print "%%A"

:print
set start=%~1

echo %start%>> "new text.txt"
goto :eof

But the simpler way of doing this would be

Code: [Select]type fileA.txt > fileC.txt
type fileB.txt >> fileC.txt
thank you thank you thank you type fileA.txt > fileC.txt
type fileB.txt >> fileC.txt

how can i set a space between them? for example, when the 2 files combine looks like this:

FileA.txt
123
1234

FileB.txt
9876
987

combined looks like this:
123
12349876
987

So need a space
What about combine and remove duplicates at the same time?

type A.txt > C.txt
echo. >> C.txt
type B.txt >> C.txti combine 2 small files and i got this , i want no space between, please :
type A.txt > C.txt
echo. >> C.txt
type B.txt >> C.txt

1kallo1209:guacharaca1209
2ivanmanoel98:manoel
3karolmelendez:970519190597
 
4romeucastro:hilda102030
5franciellyfep:dream2008
6lethiciamarfil:94071800The simple way to combine text files would be:

copy file1.txt + file2.txt file3.txt

You can also use wildcards.

See this MS info: https://support.microsoft.com/en-us/kb/69575

The reason why some files combine with the last line of file1 and the first line of file2 combined has to do with WHETHER the first file has a CR/LF at
the end of the last line or not.  It would be difficult to write a batch file that could determine if the last line has a CR/LF and add it if not.  The easiest way would be to SIMPLY add a CR/LF to every file.  This could result in 2 blank lines between some files.

You could create a file named crlf.txt using notepad.  Open that file and press the Enter key once then SAVE the file.  If you WISH to add a CR/LF to the end of a file you can simply use:

copy file1.txt + crlf.txt file2.txt

I don't know of a way to remove the CR/LF from the end of a file via a batch file.

He's not the OP...3rd Topic he's horned in...

Message sent...still not working,result:


1kallo1209:guacharaca1209
2ivanmanoel98:manoel
3karolmelendez:9705191905974romeucastro:hilda102030
5franciellyfep:dream2008
6lethiciamarfil:94071800 Quote from: siriguk on May 12, 2015, 08:04:45 AM
uhh the result is,still not working:
1kallo1209:guacharaca1209
2ivanmanoel98:manoel
3karolmelendez:9705191905974romeucastro:hilda102030
5franciellyfep:dream2008
6lethiciamarfil:94071800

You need to start your own Topics as mentioned...instead of piggybacking on existing ones...

Thank You.ok Patio i apologies , u right


Discussion

No Comment Found