How to merge multiple text files in TSE 2.5 for DOS?

53 views
Skip to first unread message

Clueless in Seattle

unread,
Aug 26, 2012, 1:22:07 PM8/26/12
to SemWare TSE Pro text editor
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...

Last night I started manually reading-in each file into a new file,
and it became so tedious that I quickly gave up the exercise.

I'm running TSE 2.5 for DOS. I'm casting about for ideas for a macro
that could read those files, one-by-one, in chronological order, into
one large text file. I think the trick would be to find a way for the
macro to keep count of the files as it works its way through them.

Any suggestions?

Robert Seely

unread,
Aug 26, 2012, 1:35:44 PM8/26/12
to SemWare TSE Pro text editor
Why not use the DOS command

copy logfile.001+logfile.002+logfile.003+logfile.004 logfile.txt

(this is even easier with a better commandline, like 4DOS (as it used
to be) or TakeCommand).

You could create a simple batch file (using TSE!), as follows, if you
have LOTS of files to combine. Do a directory listing

dir logfile.* > combine.bat

(or whatever you want to call the batch file), then edit that file to
put all the filenames on a single line, with "+" between them, and the
"copy" command at the beginning, and the target file at the end.

I think if you add the switch "/n" , as in

copy /n logfile.001+logfile.002+logfile.003+logfile.004 logfile.txt

then you can test this without actually changing anything or creating
a new file, just in case you want to try the syntax first.

Hope this helps.

-= rags =-
--
<ra...@math.mcgill.ca>
<www.math.mcgill.ca/rags>

Michael Boyd

unread,
Aug 26, 2012, 1:41:44 PM8/26/12
to sem...@googlegroups.com
Attached is a sample batch file that can copy multiple files into one. You
could also create a batch file using TSE to rename your files.

You can rename YYY.txt to yyy.bat and modify it to work. Let me know if you
need help. I'll work pro bono.

Michael Boyd
YYY.TXT

Rick Bradley

unread,
Aug 26, 2012, 3:22:21 PM8/26/12
to sem...@googlegroups.com
It's been a long time but I think this will work in a batch file

From the command line in the diskette drive
dir logfile.* /b > c:\somedir\dirlist.txt

Edit the resulting file so that the first line reads
type a:\logfile.nnn > c:\somedir\bigfile
and subsequent lines read
type a:\logfile.nnn >> c:\somedir\bigfile
Save it as a batch file and run it
Skip the first line for subsequent diskettes

Fine tuning with the appropriate drives and directories would of course be
required.
Regards
F.J. (Rick) Bradley
F.J. Bradley & Associates
http://www.fjbradley.com/
tel 519 354 4604
265 Oxley Dr. Chatham, ON, Canada N7L 4S8

Never ascribe to malice, that which can be explained by incompetence.
--Napoleon Bonaparte


Larry

unread,
Aug 26, 2012, 4:07:47 PM8/26/12
to sem...@googlegroups.com
/***
Batch files are a good solution for DOS tasks, but some of them can be
done with macros. Haven't worked with TSE 2.5 in a while, but this macro
should work.

The following macro will create a blank NewFile() and will then
numerically insert the files on Disk Drive A: according to the filename
convention you mentioned in your message. That is to say, it will find
and insert the numerica file extensions of the files on drive a: from
lowest to highest, however many there are.

After the macro inserts each file, it also inserts a separator line of
asterisks and the actual filename of the file being inserted.

At the end, a message box tells you how many files were inserted from
the disk.

This may not be what you want, but you can adapt it however you wish.
For instance, you could add a prompt at the end to rename the NewFile
name.

***/


// jigmerge.s - merge files on disk to one file in tse

proc main()

string fn[_maxpath_]=""
integer i=0

newfile() // create file to put merged files

loop
unmarkblock()
i=i+1 // keep count
// fn=*rev1"+format(str(i):3:"0")+".s" // test line

// create the filenames as described in message
fn="a:\*."+format(str(i):3:"0") // real line

// see if the file exists on disk
if fileexists(fn)
// if it does, insert it
endfile()
begline()
addline()
addline(format("*":query(rightmargin):"*")) // merged text separator
begline()
addline(fn) // merged text filename
addline()
addline()
pushkey(<enter>) // bypass pickfile window
insertfile(fn)//,_dont_prompt_) // insert the file
else
goto ending
endif
if keypressed() goto ending endif
endloop

goto ending
ending:

sound(9000,90)
warn(str(i-1)+" Files Were Merged.") // total files merged

end




-----Original Message-----
From: Clueless in Seattle
Sent: Sunday, August 26, 2012 12:22 PM
To: SemWare TSE Pro text editor
Subject: [TSE] How to merge multiple text files in TSE 2.5 for DOS?

Larry

unread,
Aug 27, 2012, 12:13:45 PM8/27/12
to sem...@googlegroups.com
/***
Okay, the jigmerge.s will do as it says, but, unfortunately, there could
be a problem. :}

Say your disk has 25 files named logfile.001 to logfile.025 but
logfile.010 is missing. Jigmerge will stop at logfile.009.

This jigmerge2.s uses a different approach. This macro places a bare
directory of the disk in drive A: into a file, then loads the file and
processes each filename by inserting it into the merge file in the
sorted order they appear on the disk. This should result in a proper
merging of the files sequentially from lowest extension to highest
extension.


I also added the assigned key <ctrlshift x> to make executing the macro
a bit easier.

And, I also added an automatic filenaming routine. The filename will use
the name "lfdisk.###" with ### being the buffer number of the file. The
macro will also use your TSE home path in the filename. You can comment
it out if you like.

(NOTE: For the merge file naming, the expectation is that your will do
all of your merging during one TSE session. Otherwise, there could be a
naming conflict since the naming uses the buffer number of the mew
merged file as its extension.)

As before, the assumption is that you are getting files from a disk on
drive A: and that the file extensions are numeric from a low number like
.001 up to a possible high number of .999. Also, ALL of the files on any
single disk will be merged even if they do not have the numeric
extension...this can easily be changed to ONLY do numeric extensions,
but the assumption is that these are the only files on your disks to be
merged.

Execute the macro for each disk you place in drive A:.

***/

// jigmerge.s - merge files on disk to one file in tse

<ctrlshift x> execmacro("jigmerge2")

proc main()

string tmpfn[_maxpath_]=loaddir()+"logfile.tmp" // the a: directory list
string fn[_maxpath_]="" // each filename in tmpfn list

integer tb=0 // the target merge file buffer id
integer wb=0 // the tmpfn buffer id

integer count=0 // total files merged

tb=newfile() // create file to put merged files

// merge file naming routine
changecurrfilename(loaddir()+"lfdisk."+format(str(tb):3:"0"))

// my test directory line
//dos("dir "+loaddir()+"mymac\jigp*rev1*.s /b > "+tmpfn,_dont_prompt_) // my
test line

// get directory of disk A:
dos("dir a:\logfile.* /b > "+tmpfn,_dont_prompt_) // for disk A:
wb=editfile(tmpfn)
begfile()

// merge the disk a: files to one file in numeric order
repeat
unmarkblock()
fn=gettext(1,currlinelen())//loaddir()+"mymac\*rev1"+format(str(i):3:"0")+".s"
// test line
gotobufferid(tb)
endfile()
begline()
addline()
addline(format("*":query(rightmargin):"*")) // merged text separator
begline()
addline(fn) // merged text filename
addline()
addline()
insertfile(fn,_dont_prompt_) // insert the file
count=count+1
if keypressed() goto ending endif
gotobufferid(wb)
until not down()

goto ending
ending:

if wb
abandonfile(wb)
endif
gotobufferid(tb)
begfile()
sound(9000,90)
updatedisplay()
warn(str(count)+" Files Were Merged. ") // total files merged
unmarkblock()

end



-----Original Message-----
From: Clueless in Seattle
Sent: Sunday, August 26, 2012 12:22 PM
To: SemWare TSE Pro text editor
Subject: [TSE] How to merge multiple text files in TSE 2.5 for DOS?

Message has been deleted

Clueless in Seattle

unread,
Aug 28, 2012, 11:56:25 AM8/28/12
to SemWare TSE Pro text editor
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 bowled over by all of time and effort you guys have put into
working out proposed solutions to my problem. You can't know how much
it means to me to have you guys helping me out on this.

I'm especially impressed by all the work that Larry has put into that
macro. Whew!

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 have to confess that just looking at all the steps in that macro has
me feeling overwhelmed. But I'm hoping that it will be a fun exercise
to try to pick it apart to figure out exactly how it works step-by-
step.

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?

Thanks again for all the help this project. Thanks to you guys I've
found a new sense of purpose in my declining years,

Will in Seattle
a.k.a. "Clueless"

Clueless in Seattle

unread,
Aug 30, 2012, 4:31:11 PM8/30/12
to SemWare TSE Pro text editor


On Aug 26, 1:07 pm, "Larry" <hayes_sm...@hotmail.com> wrote:

> // jigmerge.s - merge files on disk to one file in tse
>
> proc main()
>
> string fn[_maxpath_]=""

Hi Larry,

I decided to try the shorter macro first, since it is not as complex,
and got as far as the first command. I hunted through my manual and
couldn't find _maxpath_. The index was no help, but by going through
the manual page by page I came across _maxlength_. At least I think
that's what it said. I should have put a bookmark in the manual
because now I can't find it. May I substitute _maxlength_ for
_maxpath_ in the macro?

Just for the heck of it I tried compiling it to see what would happen.

I got two errors:

Error 103 (5.11) Unknown key word '_maxpath_'

Error 185 (40,11) ')' expected

I looked at that line and counted the parentheses, and there seem to
be just two pair. So I can't see where that extra parenthesis mark is
supposed to go.

Time for my nap!

Larry

unread,
Aug 30, 2012, 9:20:28 PM8/30/12
to sem...@googlegroups.com

Okay, just change _maxpath_ to the number 255

The _maxpath_ error may be responsible for the missing parenthesis error,
but more likely, one of the source lines became wrapped when you copied it
to be compiled. From curiosity, what is your window width? I may have to
send that macro by attachment if your screen width is to small.

As I mentioned in the second macro, the first one will work if all the
numeric extensions have no missing numbers. If you have logfile.001 to
logfile.025, and logfile.010 is missing, the macro will stop at logfile.009.
The second macto, jigmerg2.s, should fix that problem.

Didn't you used to write macros? Hopefully, it will all come back to you...




-----Original Message-----
From: Clueless in Seattle
Sent: Thursday, August 30, 2012 3:31 PM
To: SemWare TSE Pro text editor

Spamless in Seattle

unread,
Aug 31, 2012, 10:42:11 AM8/31/12
to sem...@googlegroups.com
On 8/30/2012 6:20 PM, Larry wrote:

> Okay, just change _maxpath_ to the number 255

OK; just did that. And also deleted the line that gave the parenthesis
error (it turned out to be the line that gave the beep upon completion).

And then it ran perfectly! Thanks a million for figuring out how to do
this, Larry.

I've now got a 1400k file open in TSE containing the text of all 91
files from my original floppy. And it only took a few seconds to create
the file. That's amazing!

But, when I tried to save that file to my RAM drive E:

I got this error message: "Open error: [unnamed-1] Press <Escape>"

I looked in the index of my TSE User's Guide trying to find out what
that error means. But there is no index entry for "error codes"

Do you know what that error message means? And what I need to do to
correct the problem?

> Didn't you used to write macros? Hopefully, it will all come back to you...

Hard to believe, isn't it? Sad but true though.

About a decade or so ago I switched from VDE to TSE (after trying out a
number of other text editors along the way) and TSE became my editor of
choice.

I did write a few macros for it back then. Most of them just called
sequences of complex DOS batch files that I had written during the
previous decade.

By the time I started using TSE I was already suffering from troubling
cognitive deficits from chronic illness that were exacerbated by
frequent temporal lobe seizures that left huge holes in my memory. My
disabling physical symptoms worsened to the point that I lost my job and
housing and was homeless for a while, so I had to toss out a lot of
stuff but was able to put my computer disks into storage.

Once I got back into stable housing and started receiving helpful
treatment for my illness I tried to get TSE up and running again, but
the hand-me-down laptop I was running it on died, so the project lay
dormant for a number of years.

It's only in the last few months that I've made a concerted effort to
resurrect my old TSE note-taking system, by making it a habit to work on
this project for an hour each day, first thing in the morning, the time
of day when I have the most energy and am better able to concentrate.

So, most of what I had learned about TSE in the short time that I had
used it back around the turn of the century has been been pretty much
erased by the passage of the years, the repeated seizures, and my
worsening cognitive deficits.

Thanks for the encouragement, Larry! It *is* coming back to me, albeit
very slowly, and in small pieces.

Larry

unread,
Aug 31, 2012, 12:47:57 PM8/31/12
to sem...@googlegroups.com

Sure. You have to rename the file to a legitimate filename. I had thought to
put in an automatic renaming routine, but decided that I could not read your
mind and know what you wanted the names to be, so I left it out.

The second macro does automatically rename the new merged file, but you can
easily change that name, too.

Hopefully, you will be able to re-learn some macro language...there's
nothing more stimulating that structuring a problem in your mind and then
finding the macro stuff to accomplish it.

-----Original Message-----
From: Spamless in Seattle
Sent: Friday, August 31, 2012 9:42 AM
To: sem...@googlegroups.com
Subject: [TSE] Open error: WAS: How to merge multiple text files in TSE 2.5
for DOS?

Clueless in Seattle

unread,
Aug 31, 2012, 1:16:07 PM8/31/12
to SemWare TSE Pro text editor


On Aug 31, 9:48 am, "Larry" <hayes_sm...@hotmail.com> wrote:
> Sure. You have to rename the file to a legitimate filename.

Thanks, Larry!

In between my earlier post and reading your most recent post I fiddled
around a bit and figured out that I have to name the file *before*
trying to save it. My error was that I was expecting a prompt asking
me for a file name *after* I entered the "Save File" command.

So I've now got one set of 91 small files merged into a single large
file, (thanks to your patience and diligence).

> Hopefully, you will be able to re-learn some macro language...there's
> nothing more stimulating that structuring a problem in your mind and then
> finding the macro stuff to accomplish it.

I know what you mean!

Years ago I decided to write a little GW-BASIC flashcard style program
to help me learn Spanish vocabulary. It started out with about 8 or
10 lines of code.

But I kept thinking of enhancements that I could add, and soon it had
ballooned to pages and pages and pages of code and sub-routines and
sub-sub-routines and was taking up all my time. I no longer used it
for practicing Spanish. It had become an end in itself. I could not
stop working on it.

Fortunately for me, the laptop I was using to work on it died, and I
dropped the project before it ate me alive.

Thanks again for sticking with me and seeing me through to the
completion of this macro. It means a great deal to me.

Larry

unread,
Aug 31, 2012, 8:05:34 PM8/31/12
to sem...@googlegroups.com

By the way, I just remembered that TSE 2.5 does not support long filenames.
So, if you decide to use the second macro, jigmerge2.s, change its name to
one with 8 characters in the filename.

Also, if you want to use the assigned key, change the line in the source:

<ctrlshift x> execmacro("jigmerge2")

to your new macro name, such as:

<ctrlshift x> execmacro("merge2")

It's been a long time since I used it. :) Too bad you can't get a new
computer and upgrade to TSEPRO 4.4, which is what I use.


-----Original Message-----
From: Clueless in Seattle
Sent: Friday, August 31, 2012 12:16 PM
To: SemWare TSE Pro text editor
Subject: [TSE] Re: Open error: WAS: How to merge multiple text files in TSE
2.5 for DOS?



Reply all
Reply to author
Forward
0 new messages