1

Sup people!

I have a problem with multiple txts files that i need to merge, something like that.

Folder 1:

1.txt
2.txt
3.txt

Folder 2:

1.txt
2.txt
3.txt

Folder 3:

1.txt
2.txt
3.txt

And i need to merge all the txt with the same filenames in something like this.

Folder 4:

1.txt
2.txt
3.txt

With the merge of all the folders from 1 2 3

They are like 200 txts for 3 folders and i need a little bit of help, tried to doing it manually with a bat and copy /b *.txt filename.txt but they are too much txts files.

PD: I need something that doesn't change the names of the txts and remain the same, something to autodetect and don't touch the filenames.

Pic : http://puu.sh/nhnwC/cb309a44f5.png

From 3 folders.

Thanks!

Marc B
  • 356,200
  • 43
  • 426
  • 500
  • `cd folder1; for %f in (*.*) do copy /b %f + ..\folder2\%f + ..\folder3\%f ..\folder4\%f)` – Marc B Feb 22 '16 at 16:14
  • Possible duplicate of [How to merge text files with the same name from all subdirectories?](http://stackoverflow.com/questions/34145656/how-to-merge-text-files-with-the-same-name-from-all-subdirectories). Also Related: [combine lots of files](http://stackoverflow.com/questions/3418549/need-to-combine-lots-of-files-in-a-directory) and [merge multiple csv files with batch](http://stackoverflow.com/questions/25596171/merge-multiple-csv-files-using-batch-file) – LinkBerest Feb 22 '16 at 16:17
  • @marc-b thanks for your reply! I am trying the way you posted it there but its giving me The system couldn't found the specify route. Screenshot : http://puu.sh/nhpqk/00d572764a.png. Folders and GSA list. http://puu.sh/nhprO/b77530f12a.png and the TXT with the way you put it. http://puu.sh/nhpt7/8404e3d7eb.png Sorry for not knowing how to solve it! and thanks you again Marc! – Alejandro Martín Feb 22 '16 at 16:36
  • @MarcB I've replied to the question with more info about this issue! – Alejandro Martín Feb 22 '16 at 17:13
  • `for /D %%a in (*) do for %%b in ("%%a\*.txt") do type "%%b" >> "Folder 4\~NXb"` – Aacini Feb 22 '16 at 17:21
  • 1
    @aacini Thanks for your reply! It worked like a charm, but it created a file called NXB of 2.7GB of data and thats not the purpose i need! I need to maintain filenames and the splitted files like this screenshot http://puu.sh/nhnwC/cb309a44f5.png – Alejandro Martín Feb 22 '16 at 17:36
  • @Aacini shouldn't `~NXb` be `%%~NXb`? – Dennis van Gils Feb 22 '16 at 17:50
  • @DennisvanGils: Ops! My mistake! Insert the fix from Dennis – Aacini Feb 22 '16 at 17:51
  • So, for clarification: `for /D %%a in (*) do for %%b in ("%%a\*.txt") do type "%%b" >> "Folder 4\%%~NXb"` – Dennis van Gils Feb 22 '16 at 17:51
  • @DennisvanGils It worked like a charm! Thanks you! And thanks everyone! – Alejandro Martín Feb 22 '16 at 17:57
  • That should be happening with that code, just tested it. My comment is the fixed one. – Dennis van Gils Feb 22 '16 at 17:59

0 Answers0