Page 1 of 1

join/append txt file from c:\mydir\

Posted: 25 Aug 2017 06:51
by sal21
in c:\mydir\ have 87 .txt files.

i need via batch code, to append all lines from each .txt files in one big .txt file...
How to?

Re: join/append txt file from c:\mydir\

Posted: 25 Aug 2017 08:22
by pieh-ejdsch
Hello,

did you mean so? at command promt:

Code: Select all

@(for /f "delims=" %i in ('dir /b C:\mydir\*.txt') do @for /f usebackQdelims^=^ tokens^=*^eol^= %j in ("%i") do @ <nul set /p "=%j") >C:\mydir\oneBig.txt.log

Phil

Re: join/append txt file from c:\mydir\

Posted: 25 Aug 2017 09:29
by miskox
sal21 wrote:in c:\mydir\ have 87 .txt files.

i need via batch code, to append all lines from each .txt files in one big .txt file...
How to?


If they are in the correct order you can use this:

Code: Select all

copy *.txt new_file.txt


(this new_file.txt will have an EOF character at the end of file)

or

Code: Select all

copy /b *.txt a.a new_file.txt


(this new_file.txt will not have an EOF character at the end of file)

Hope this helps.

Saso