Is there a way to combine text files using the Windows command line?

23,795

Solution 1

You can also use the copy command, eg

copy *.js bigfile.txt

or, for specific files

copy file1.txt+file2.txt+file3.txt bigfile.txt

Solution 2

type * > someotherpath/all.txt

The need for creating the file somewhere else is that if the new file is created on the same folder, it should be excluded from the selection.

Also, filtering by extension and using a different one for the resulting file would work. For example:

type *.js > all.txt
Share:
23,795

Related videos on Youtube

electrogas
Author by

electrogas

Updated on September 17, 2022

Comments

  • electrogas
    electrogas over 1 year

    I am thinking looking for a way to combine all the .txt files in a directory into a single one .txt file.

    Is there a way to combine text files using the Windows command line?

  • Joe_Rose
    Joe_Rose over 13 years
    +1 - This also allows you to decide what order to have the combined result set in.
  • Torbjörn Hansson
    Torbjörn Hansson over 11 years
    This included the BOM in my textfiles so I fixed it my using type commando (see DanC's answer) (superuser.com/a/191234/56861).