preserve empty lines while merging files [SOLVED]

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

preserve empty lines while merging files [SOLVED]

#1 Post by abc0502 » 27 Aug 2012 01:44

Hi, I don't know what is happining but i'm now trying to merge several files together, and they have empty lines,
i need this lines to be there in the merged file,
I tried counting lines and echo it to the final file.
Tried using a for loop with all txt files and this command with the for loop

Code: Select all

echo %%a>>file.txt

Tried the same for loop but with type

Code: Select all

type %%a>>file.txt


I can't use the copy file1+file2+file3 file.txt because i don't know the names or how many files they are i'm using the for loop to get all files in directory and all files will be stored in the %%a variable

any idea?
Last edited by abc0502 on 27 Aug 2012 03:55, edited 2 times in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: preserve empty lines while merging files

#2 Post by foxidrive » 27 Aug 2012 03:44

Is it all the .txt files in a folder?

Code: Select all

copy *.txt a.tmp
ren a.tmp "filename.txt"

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: preserve empty lines while merging files

#3 Post by abc0502 » 27 Aug 2012 03:55

foxidrive wrote:Is it all the .txt files in a folder?

Code: Select all

copy *.txt a.tmp
ren a.tmp "filename.txt"

yes all files are .log and in one folder.

I can't belive how simple is the solution :o
It works :D

Thanks Foxidrive

Post Reply