I create a small batch file wich will merge some textfiles
type %1 >> %2
but some textfile don't end with a carriage return and the last line of one
file will by append with the first line of the next file.
How can I add an
carriage return or a line feed ?
Thanks in advance
Ralf
echo.>>file.txt
You will be left with the problem of some files ending in a blank line, and
some not.
> > I created a small batch file wich will merge some textfiles
> > type %1 >> %2
> >
> > but some textfile don't end with a carriage return and the last line
> > of one file will by append with the first line of the next file.
> >
> > How can I add a carriage return or a line feed ?
> echo.>>file.txt
> You will be left with the problem of some files ending in a blank line, and
> some not.
*** I don't think that is a big problem.
For Ralf. Try this. It will add a blank line to each text file name you
type at the command line, and them combine them. It is untested.
:: COMBINE.bat
:: Adds a Blank Line to up to Five .txt Files
:: Combines up to Five .txt Files
::
@ECHO OFF
FOR %%T in (%1.TXT %2.TXT %3.TXT %4.TXT %5.TXT) DO ECHO. >> %T
COPY %1.TXT + %2.TXT + %3.TXT + %4.TXT + %5.TXT COMBINE.TXT
Richard Bonner
http://www.chebucto.ns.ca/~ak621/DOS/
>I create a small batch file wich will merge some textfiles
>type %1 >> %2
>
>but some textfile don't end with a carriage return and the last line of one
>file will by append with the first line of the next file.
>
>How can I add an
>carriage return or a line feed ?
You do not, or should not, mean that. Text file newlines should all be
two characters, carriage-return line-feed.
If you pipe $1 through any HLL program that copies line-by-line, the
ends of lines, including the last will be normalised, but no lines
should be added.
Therefore, try
COLS <%1 1- >>$2
COLS via sig line 3 below. NOTE - maximum line-length 255 characters.
Check what happens if the file may contain control characters such as
FF, VT, BS.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; Win98. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
G'day Ralf,
>I create a small batch file wich will merge some textfiles
>type %1 >> %2
>
>but some textfile don't end with a carriage return and the last line of one
>file will by append with the first line of the next file.
>
>How can I add an carriage return or a line feed ?
I have a small file (2 bytes) called ANSWER.NUL which contains only
the characters (in hex) 0D 0A (i.e. CR/LF) which I've used over the
years as a "response" where needed in batch files.
It can also be used by redirection to append the standard CR/LF pair
to files such as you describe.
Unfortunately, it is now 14 years old, and I'm damned if I can recall
how I made it! Quite possibly I used that old workhorse EDLIN, but
that seems to have disappeared from modern systems, so I couldn't try
it for you on this machine.
Given all that, this info is probably quite useless for your purpose.
But then, it may provoke someone to a more practical response!
(One has to be optimistic. ;-)
Cheers, Phred.
--
ppnerk...@THISyahoo.com.INVALID
> In article <411a3a0e$0$3198$626a...@news.free.fr>, "Ralf Meuser" <rme...@free.fr> wrote:
>>How can I add an carriage return or a line feed ?
> I have a small file (2 bytes) called ANSWER.NUL which contains only
> the characters (in hex) 0D 0A (i.e. CR/LF) which I've used over the
> years as a "response" where needed in batch files.
>
> It can also be used by redirection to append the standard CR/LF pair
> to files such as you describe.
>
> Unfortunately, it is now 14 years old, and I'm damned if I can recall
> how I made it!
With a batch file :)
echo.>ANSWER.NUL
Although 14 years ago the echo command couldn't echo a blank line/CRLF, if
my memory is not totally fscked up.
echo.>answer.nul
should suffice; or use any plain text editor worthy of the name.
But to add CRLF only to those files that need it requires a means of
identifying them. Minitrue can be used, too, ISTM :-
mtr -x+ ? ([^\n])\Z = \1\r\n
so perhaps SED will do it?
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/> Update hope?
> echo.>ANSWER.NUL
> Although 14 years ago the echo command couldn't echo a blank line/CRLF,
*** It has been able to use "ECHO." since at least MS-DOS 5, released
in 1991. However, I vaguely remember seeing a technique for issuing a
blank line before that, but can't remember the syntax.
That aside, at that time, one could have used a blank-line file to
insert a blank line, as has already been suggested here.
Richard Bonner
http://www.chebucto.ns.ca/~ak621/DOS/
Yeah. Your method certainly works. However, my old file is actually
dated 1 Dec 1990 (just after afternoon smoko by the time stamp :) but
I guess that's not *quite* 14 years ago. ;-)
Following up on Stocko's comment about text editors, I tried both
Notepad and EDIT under Win ME and, indeed, both were happy to create a
2-byte file of only CR/LF but the way to do it was subtlely different:
Notepad: Enter a blank line and Save As
EDIT: Simply open a new file by invoking EDIT and immediately Save As
(If you do as in Notepad, you get 4 bytes -- CR/LF/CR/LF)
Cheers, Phred.
--
ppnerk...@THISyahoo.com.INVALID
A copy of Amstrad DOS 3.3, with command.com dated 1987-07-24, executing
echo.>a:x , has just generated a file containing exactly two characters,
OD OA .
--
echo.>>file.txt
of course, this actually adds a CR+LF under DOS, not just a CR.
In the original post,
type %1 >> %2
could perhaps have been replaced with copy %1+%2 %2
(depending on what version of DOS it is, this may not work, as it may not
allow overwriting one of the sources - the destination would have to be a
third file)
then, the "answer file" thing could be incorporated as something like
copy %1+answer.nul+%2
In article <2o9ckjF...@uni-berlin.de>, ppnerkDE...@yahoo.com (Phred)
wrote:
As I have recently posted:-
Debug can be used to create files with ANY contents up to
about 64k in length.
Steps-
Create a file < 64k long.
e.g. echo fred > file.txt
now debug the file
debug file.txt
You can then view the file with the d command (dump?).
the file is loaded into memory at address 100 (HEX)
The q command quits from debug.
Change the length of the file with the rcx command and enter
the desired length in HEX.
Edit bytes with the e command {space} to leave unchanged
{enter} to finish editing
Write with w which writes cx register's worth of data.
You can get the debug commands from a file (or pipe?)
debug fred.txt < d-file
Extensive example of this posted to this group today.
I suspect debug is limited to 8.3 filemanes.
H:\temp>echo fred > file.txt
H:\temp>dir file.txt
19/08/2004 13:51 7 file.txt
H:\temp>
H:\temp>debug file.txt
-d
0C6F:0100 66 72 65 64 20 0D 0A D0-C0 24 01 D0 E4 0A C4 C3 fred ....$......
0C6F:0110 1E E8 E4 FF 8E 1E FE 95-A2 14 06 80 34 00 5E 0C ............4.^.
<snipped>
-rcx
CX 0007
:2
-e 100
0C6F:0100 66.0d 72.0a # only 0d{space}0a typed
-w
Writing 00002 bytes
-q
H:\temp>dir file.txt
19/08/2004 14:10 2 file.txt
H:\temp>
___________________________________________________________
If you think debug is limited to 64K bytes, add these lines and continue.
-rbx
BX 0000
:ff
But you better have 16,711,680 more bytes of disk space available.
I don't recall the results if you don't have 16M memory available.
___________________________________________________________
> Debug can be used to create files with ANY contents up to
> about 64k in length.
Up to? No, debug can create files much larger than 64KB.
--
Todd Vargo (remove hyphen to reply by email)
Thanks, I didn't know that the length written was bx:cx.
That is (bx << 8 ) + cx.
The bigest files that I have ever written with debug were .com
files and as you will know (or will be correcting me shortly)
they are limited to 64k (less PSP?).
a bit more work needed to fill with data though
Have you ever patched a large .EXE file? I have, but only under duress!
It's almost as much fun as using a disk sector editor to apply a patch.
Floppy disk editing and recovery was the reason why I became interested
in using debug for other purposes than quick and dirty programming.
_______________
@goto run
'AMBR.bat
'put a disk in drive A:
l100 0 0 1
d100 l200
q
q
:run
debug<AMBR.bat
_______________
Shows you the contents of the first sector of a floppy in A:.
Use a 50 line screen to see all of it, or output to a file.
If you want to save a copy, add a name, cx=200, and write before the q's.
Sorry, I was not aware this is now alt.msdos.debug :-/
Besides, as I expected, someone did shortly after I posted.