concatenate multiple txt files with line break in BAT

1

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

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

Wrong:

  

dog zebra cat

Correct:

  

puppy
  cat   zebra

Does anyone know how to help me?

    
asked by anonymous 04.12.2017 / 13:56

1 answer

0

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

Creating Batch Commands .bat :

1. Open Notepad and copy the code below.

2. Save the file and close Notepad.

3. Rename the file you just saved by changing the extent of .txt to .bat .

4. Now just double-click the .bat file to run it.

  

To join the .txt files you want, they must be in the same   directory of the .bat file.

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 .bat :

move juntos.txt D:\nome_da_pasta/

If it is a subfolder where .bat is, just:

move juntos.txt nome_da_pasta/
    
04.12.2017 / 15:52