Computing.Net > Forums > Disk Operating System > Batch file to create/edit text file

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.

Batch file to create/edit text file

Reply to Message Icon

Name: gnitelady
Date: February 13, 2002 at 10:06:39 Pacific
Comment:

I need to create a batch file to which I can pass 2 parameters to create, type and save a text file. Edit and copy con require additional keystrokes outside the batch file. Is there a way to create and edit a text file in batch without user intervention?



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: February 13, 2002 at 20:41:58 Pacific
Reply:

Yes, there is.
Let me see if I've understood it:
You have a script, and you pass two parameters to it:

script.bat string1 string2

Then you want it to create a text file with:
=== Textfile begin ===
string1
string2

=== Textfile end ===

Is that it?
If YES, here it goes:


@echo off
if "%2"=="" goto eof
echo %1> file.txt
echo %2>> file.txt
:eof


We don't need to hardcode the filename. In the following script, the first parameter is the filename, and the second and third are the strings:


@echo off
if "%3"=="" goto eof
echo %2>%1
echo %3>>%1
:eof


Was that really what you were looking for?

-- Secret_Doom - Leonardo Pignataro --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 2
Name: Mick
Date: May 7, 2002 at 03:28:11 Pacific
Reply:

I used the Edlin command which allows you to edit text. It is very rudamentary though. I've been able to get Edlin to crop all lines of text above and below the line that I wanted to save in a text file from a bat file, however I can't crop individual characters. Syntax is tricky. Edlin is old and has few commands.


0

Response Number 3
Name: Mick
Date: May 7, 2002 at 04:20:46 Pacific
Reply:

To use Edlin you need to call it from your batch program like this:
EDLIN EXAMPLE.TXT < INPUT.ED
where EXAMPLE.TXT is your text string. INPUT.ED is a file which you must create. Just make a new text document and rename it INPUT.ED. INPUT.ED contains all the text editing strokes that you want performed on your string/s. Enter your series of commands and save INPUT.ED into the same directory as your BAT file.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


dos6.22 upgrade disks DOS Prompt



Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Batch file to create/edit text file

Dos Batch file www.computing.net/answers/dos/dos-batch-file/5691.html

read a file from a batch file??? www.computing.net/answers/dos/read-a-file-from-a-batch-file/16657.html

batch files www.computing.net/answers/dos/batch-files/1036.html