Computing.Net > Forums > Windows XP > Reading and writing to a file in DOS

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Reading and writing to a file in DOS

Reply to Message Icon

Name: Stphens
Date: August 5, 2009 at 21:46:56 Pacific
OS: DOS
Subcategory: Installation
Tags: DOS, MSDOS commands, FOR statments
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: Wahine
Date: August 6, 2009 at 02:12:30 Pacific
Reply:

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?


0

Response Number 2
Name: Stphens
Date: August 6, 2009 at 17:27:22 Pacific
Reply:

Yes that is correct it will be running from a shell - either XP or Windows 2003. CMD


0

Response Number 3
Name: alan1000
Date: August 7, 2009 at 07:33:43 Pacific
Reply:

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.


0

Response Number 4
Name: Stphens
Date: August 9, 2009 at 18:44:37 Pacific
Reply:

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.



0

Response Number 5
Name: Wahine
Date: August 9, 2009 at 20:42:49 Pacific
Reply:

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


0

Related Posts

See More



Response Number 6
Name: Stphens
Date: August 10, 2009 at 21:19:06 Pacific
Reply:

TOO GOOD.
thankyou for that, did what I needed.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Drag and drop files corru... reregistering jscript



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Reading and writing to a file in DOS

Need to find file in xp boot disk www.computing.net/answers/windows-xp/need-to-find-file-in-xp-boot-disk-/44712.html

how to copy files in dos? www.computing.net/answers/windows-xp/how-to-copy-files-in-dos/103189.html

Need to Delete file through Dos www.computing.net/answers/windows-xp/need-to-delete-file-through-dos/69380.html