Reading and writing to a file in DOS

August 5, 2009 at 21:46:56
Specs: DOS
hello
Ive read a bit about reading and displaying a single line from a text file to the screen. But I'm after (if possible) to read a file copy a part of it and copy/inset it in to another file.

So the data file is c:\datafile.txt:

---------- A.TXT

B.BBBBB?something.com.au DDDDD


and output c:\datafile2.txt
B.BBBBB?something.com.au


anyhelp would be great.


See More: Reading and writing to a file in DOS

Report •


#1
August 6, 2009 at 02:12:30
You've posted in the Win XP forum. Which version of Dos are you using or do you mean the Win XP Dos emulator program CMD.exe?


Report •

#2
August 6, 2009 at 17:27:22
Yes that is correct it will be running from a shell - either XP or Windows 2003. CMD

Report •

#3
August 7, 2009 at 07:33:43
Hi Stphens,

Your post is not completely clear. It sounds almost as if you have been reading about Edlin (the old DOS command line editor.)

Have you tried doing whatever it is that you want to do by using Notepad, or MS Word, or one of the hundreds of freeware text editors which you can download from the web? Or, since you mention dot com dot au, are we talking about HTML? Please provide more info!

Pure gold does not fear the furnace.


Report •

Related Solutions

#4
August 9, 2009 at 18:44:37
Hi.
Sorry about not being clear..


Lets start again.

I have a data file created with notepad called c:\datafile.txt in the datafile.txt it has the following data a few lines of information line 1 to 3 (line 3 is actually an email address and after that email address is a space than 5 charaters..


1.---------- A.TXT
2.
3.B.BBBBB?something.com.au DDDDD
EOF

Now trying to run a process which will read the datafile (c:\datafile.txt) and output it to another file called c:\output.txt
in this format.

B.BBBBB?something.com.au
EOF.

I would perfer to be able to do this in DOS MODE running on a windows XP / 2000 2003 machine.

Is it possible to do it running dos command? -

I hope that this clears up what I'm trying to do.

thanks again.



Report •

#5
August 9, 2009 at 20:42:49
This might be what you want:

@echo off
setlocal
cls

for /f "tokens=1-2" %%# in (C:\datafile.txt) do (
    
    echo %%#>c:\output.txt
)

type c:\output.txt

exit /b


Report •

#6
August 10, 2009 at 21:19:06
TOO GOOD.
thankyou for that, did what I needed.

Report •


Ask Question