Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the board
Thread view  Mix view  Order
CluelessInSeattl(R)

Seattle, USA,
26.08.2012, 19:13
 

DOS command to combine or merge text files (Users)

Hi again!

I've got a box-full of old floppy disks containing hundreds of small text files. They range in size between about 8 and 25 KB. (I think that perhaps those files are so small because I got into the habit of trying to keep files at about 15 K back when I was using WordStar in my CP/M days).

I'd like to combine all of the files on each disk into a single file that will fit onto a single floppy.

Hundreds of these files contain dated log entries so I'd like to be able to keep the text of the files in chronological order within the larger file.

The task of maintaining the chronology of the log entries should be fairly simple, because all of the file names on each disk are identical, except for the three character extension, like this:

logfile.001
logfile.002
logfile.003
logfile.etc...

So I'm casting about for a DOS command, commands, or ideas for a batch file, that would read those files, one-by-one, in chronlogical order, into one large text file.

Any suggestions?

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

ron(R)

Homepage E-mail

Australia,
27.08.2012, 00:32
(edited by ron, 27.08.2012, 00:46)

@ CluelessInSeattl

DOS command to combine or merge text files

> So I'm casting about for a DOS command, commands, or ideas for a batch
> file, that would read those files, one-by-one, in chronlogical order, into
> one large text file.
>
> Any suggestions?

Copy

e.g. copy logfile.* [filename.ext]

will combine all logfile.* files into filename.ext


Try: help copy

to see if your COPY does the same as in MS-DOS.

Doug(R)

E-mail

27.08.2012, 07:01

@ ron

DOS command to combine or merge text files

Ron's suggestion is a good one, but be cautioned: the files won't be copied chronologically unless they are already stored in chronological order on the disk -- the COPY command just copies files in unsorted directory order.

But you can sort the directory by using your Norton DirSrt utility (possibly might be named DS for short). Sort first, then copy. Piece o' cake.... (But only use DS on FAT16 or FAT12 disks / no long filenames!)

Also be aware that if you have lots of individual files, the destination file could grow very big. Most DOS 16-bit text editors / word processors have a memory limit (after all, they must fit into less than 640kb) and might not be able to handle a really-large file.

- Doug B.

ron(R)

Homepage E-mail

Australia,
27.08.2012, 08:14

@ Doug

DOS command to combine or merge text files

> But you can sort the directory by using your Norton DirSrt utility
> (possibly might be named DS for short). Sort first, then copy. Piece o'
> cake.... (But only use DS on FAT16 or FAT12 disks / no long filenames!)

That is good advice.

> Also be aware that if you have lots of individual files, the destination
> file could grow very big. Most DOS 16-bit text editors / word processors
> have a memory limit (after all, they must fit into less than 640kb) and
> might not be able to handle a really-large file.

I guess it depends on how you expect to access the destination file(s).
There are some DOS word processors that can handle large (1 MB+) text files,
and there may well be DOS text readers that can do the same (it should be
relatively easy to write one if necessary).

Alternatively, convert the destination text file into an .HTM file and use
a browser with its search ability to find stuff.

bretjohn(R)

Homepage E-mail

Rio Rancho, NM,
27.08.2012, 17:40

@ Doug

DOS command to combine or merge text files

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.

Rugxulo(R)

Homepage

Usono,
27.08.2012, 20:44

@ bretjohn

DOS command to combine or merge text files

> 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

Keep in mind that copying a zero-byte file is not consistent. I know old MS-DOS 6.2 COMMAND.COM won't copy it, but XP's CMD will! Other shells perhaps behave differently, I forget, and this breaks some (admittedly obscure, too-tricky-for-their-own-good) .BATs.

> 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

Is he sorting by file date or extension or name? Remember that pure DOS (FAT) is limited to two-second intervals, so it's not reliable if you want microsecond granularity. I know that's worrying a bit much, but it can bite.

As for sorting via DIR, that's a good idea, but again, you have to be careful. Does it sort "version" numbers correctly, e.g. ".1" comes before ".10"?? So you have to be careful. (I guess *nix "sort -n" is probably what I'm hoping for here.)

Otherwise, I guess it doesn't matter, and your solution probably mostly works (and I do similar all the time, obviously, heh).

I would almost rather just use something like REXX to generate the .BAT, but I don't guess it's good advice to say, "Download xyz to fix your problem!" Since he's using MS-DOS, it's probably idealistic (in theory) to just give him a solution in QBASIC, which I don't have right now. Just saying, in theory, use what tools are already there.

P.S. Here's a (very very rough, not totally practical) idea of what I was thinking:


#!/usr/local/bin/regina

template='file00' ; op='+' ; msg=''

do i=1 to 16
  if i = 16 then op=''
  msg = msg template || i'.txt' op
end

say 'copy' || msg || 'newfile.txt'

/*
copy file001.txt + file002.txt + file003.txt + file004.txt + file005.txt + file006.txt + file007.txt + file008.txt + file009.txt + file0010.txt + file0011.txt + file0012.txt + file0013.txt + file0014.txt + file0015.txt + file0016.txt newfile.txt
*/

Arjay(R)

27.08.2012, 21:29

@ Rugxulo

DOS command to combine or merge text files

> Keep in mind that copying a zero-byte file is not consistent. I know old
> MS-DOS 6.2 COMMAND.COM won't copy it, but XP's CMD will!
A trick I used to use to zero the contents of files/create zero byte files with earlier MS-DOS versions of COMMAND.COM was by typing "COPY NUL FILENAME.EXT"

A more reliable method to create a zero byte file:
rem >filename.ext

> this breaks some (admittedly
> obscure, too-tricky-for-their-own-good) .BATs.
Yup RJKILL.BAT circ 1991 which used COPY NUL with SET to allow RJKILL *.*

> I would almost rather just use something like REXX to generate the .BAT,
Excel is a good often overlooked method for quickly creating batch files, the important thing is to then save as .TXT (.BAT) with space as the delimiter.

CluelessInSeattl(R)

Seattle, USA,
28.08.2012, 18:12

@ Arjay

DOS command to combine or merge text files

Hi again!

I had to take a few days off from this project.

The backlight in the hand-me-down laptop I've been using for web access went dead on me a few days ago. And I had a housing authority inspection of my apartment that I had to get ready for, which just plum tuckered me out. Then a couple of days of running errands on my bicycle (I can't a afford a car) that put me to bed for a few days more.

But I've recovered somewhat and now I've got a humongous CRT monitor on a wobbly TV cart rolled up next to my bed, and I've connected it to that screen-dead laptop. And with the aid of an old pair of bifocals I'm able to just barely make out the screen, so it looks like I'm back in business, albeit it rather awkwardly so.

I'm having trouble reading the screen on this old monitor at this distance, so I may have to break down and use up some toner and print out your replies and study them the old fashioned way: on paper.

I'm afraid I won't be checking in here as often as I'd like to, until I can scare up another laptop. I do have an old PC with internet access, but due to a disabling circulation disorder, I don't do very well sitting up (my poor old heart can't get the blood up to my poor old brain, so when I sit up I get even more confused than usual; and anxious and panicky on top of that).

Do you think it would be inappropriate to post a message in this forum asking if anyone has an old laptop that they no longer use?

I'm grateful to you all for the time time and effort you have put into
working out proposed solutions to my problem. You can't know how much
it means to me to know I have virtual friends from all over the world who are willing to help me on this project. It's giving me a new sense of meaning and purpose in the declining years of my life.

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

Arjay(R)

28.08.2012, 22:53

@ CluelessInSeattl

DOS command to combine or merge text files

> I'm back in business,
Good!

> albeit it rather awkwardly so.
> I'm having trouble reading the screen on this old monitor at this distance,
I remembered there were a few MS-DOS ZOOM applications back in the day. One it seems was called ZOOMTEXT, the demo of which is certainly still available from this mirror of Simtel: Simtel - MS-DOS accessibility utils see zoomtext.zip and zoomshar.zip both of which are shareware. Sadly there isn't an index.html file for that directory or on other mirrors but might be worth while browsing through. Sorry I don't have time right now.

From what you have written I realised that you are visually impaired. I have a few acquaintances who are fully registered blind various associated complications and are able to continue with their interests, so don't give up!

Are you also aware that Freedom Scientific's "Jaws for DOS" is now freeware? It is available via their Additional JAWS for Windows Downloads page However to help: this is the direct download link for the DOS version of Jaws - I would also highly recommend checking out Jaws for Windows - it is not cheap but I would hope that you will be able to get some assistance in purchasing it from some organisation. Here in the UK were are very lucky to have the RNIB (Royal National Institute of Blind People) who continue to put out ground breaking work. They have a dedicated RNIB technology page with how to guides that may be helpful. They also publish a Access IT magazine. Obviously more focused now on Windows, but useful to know that information/help exists and available to you.


> Do you think it would be inappropriate to post a message in this forum
> asking if anyone has an old laptop that they no longer use?
I don't believe anyone will mind. However I would instead suggest putting out a message on your local Freecycle, gumtree, craigslist - however I would recommend using another email account as well as the good you may get spam, various silly messages etc. However it will be worthwhile as there are many kind people out there. I'm sure if you give a highlevel explaination of your situation in your ask that someone will happily give you a laptop, and may even offer to set it up etc.

> It's giving me a new sense of meaning and purpose in the declining years
> of my life.
Glad to hear. Fortunately the DOS world is frequented by many good people.

Back to the board
Thread view  Mix view  Order
15188 Postings in 1365 Threads, 250 registered users, 11 users online (0 registered, 11 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum