concatenate several txt files with line break in BAT

Asked

Viewed 4,001 times

1

Can anyone tell me if to add line break, for each content of each file?

For example, in a file has content (dog) and in other files other types of content, but the files have no line break at the end, thus joining the contents in the same line.

Wrong:

zebra cat dog

Correct:

dog
pussycat
zebra

Someone can help me?

  • How are you reading these files? Post the code.

  • you can add & to get the break... without seeing your code is hard to help but would be more or less: echo dog & echo cat & echo zebra

1 answer

0


You can use the commands below in a file .bat.

Creating archive of batch commands .bat:

1. Open Notepad and copy the code below.

2. Save the file and close the Notepad.

3. Rename the file you just saved by changing the extension to .txt for .bat.

4. Now just make two clicks on the file .bat to execute him.

To join the files .txt they must be in the same file directory .bat.

Code:

del juntos.txt

for %%I in (*.txt) do (
    type %%I >> juntos.tmp
    echo. >> juntos.tmp
)

ren juntos.tmp juntos.txt

EDIT

To move the final file to another directory (folder), include the code below at the end of the .bat:

move juntos.txt D:\nome_da_pasta/

If it is a subfolder from which the .bat is, enough:

move juntos.txt nome_da_pasta/
  • Opa I have to execute all these commands at the same time, because I am layman in it?

  • @Mario Edited the question with step by step. Good luck!

  • Bah very good, thanks even went right, hug!!!

  • it would be like in that same bat I give a destination where I want you to save this file?

  • @But I think there is a way...

  • @Punch put in the answer how to do this. Just move the generated file. Abs!

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.