Sum of several text files * .txt

3

I have a series of files in .txt and would like to sum them all together in one (independent of the order).

Is it possible to do this by word vba, some other text editor, or other means?

    
asked by anonymous 12.02.2016 / 02:08

1 answer

4

A relatively simple way is to use Windows CMD.

Using for + type :

cd /d c:\caminho\para\a\pasta 
for %f in (*.txt) do type "%f" >> amalgama.out

Instead of amalgama.out you put the desired output name.

You do not even have to .bat , just run right at the prompt command.

Relevant information: I used .out in the output to avoid double concatenation (add amalgama.txt to itself). Anything other than .txt works, but you should use one that is not "hidden" by Windows. Nothing that rename does not solve at the end;)

Using copy :

This is a simpler alternative, but does not force line breaks at the end of each file. It can happen to "paste" two lines if the last one of a file does not finish with a break.

cd /d c:\caminho\para\a\pasta 
copy /b *.txt amalgama.out

/b indicates "binary", but can be used with .txt s to ignore any special characters.

Of curiosity, the% wc% used in the% wc% commands above is used to change units if necessary, avoiding to run /d and cd separately if prompt is not already open in the correct drive.

    
12.02.2016 / 03:27