Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

DOS command to combine or merge text files (Users)

posted by bretjohn Homepage E-mail, Rio Rancho, NM, 27.08.2012, 17:40

In these situations, I take one of two approaches. I don't start by sorting the file using Norton or any other utility (I may not be at a computer where those are even available). The first thing I do is use REM to create a 0-length file with the appropriate (new) name:

REM > NewFile.Ext

If there are only a few files to concatenate, I use FOR at the command line with the COPY "+" (concatenate) feature:

FOR %f IN (1,2,3,...) DO COPY NewFile.Ext+OldFile.00%f

If there are more than a few files to do this to (will require more than one or two FOR commands), I create a batch file to do it. I start by using DIR to get a sorted list of files:

DIR /O /-P > DoIt.Bat

Then, I edit DoIt.Bat with a text editor (preferably a good one with a macro facility) so that it looks something like this:

COPY NewFile.Ext+OldFile.001
COPY NewFile.Ext+OldFile.002
...

Then I run the DoIt.Bat file and then erase it (after verifying that everything worked OK).

This is actually the same basic process I use when I need to do almost anything to a whole bunch of files, not just concatenate them together.

 

Complete thread:

Back to the forum
Board view  Mix view
22762 Postings in 2122 Threads, 402 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum