Computing.Net > Forums > Disk Operating System > Inserting text into files using some DOS

Inserting text into files using some DOS

Reply to Message Icon

Original Message
Name: Alex
Date: June 17, 2001 at 07:41:57 Pacific
Subject: Inserting text into files using some DOS
Comment:

I once knew a way to insert some text into a document using a batch file(i know it sounds strange..!) and im sure i used the COPY command or something like that. Could someone shed some light on this for me?
Example:
Say i wanted to add a line to an INI file like (eg) RUN=Welcome.exe into the win.ini file?
I'm sure someone will know what im geeting at! Thanks!
Al

I once knew a way to insert some text into a document using a batch file(i know it sounds strange..!) and im sure i used the COPY command or something like that. Could someone shed some light on this for me?
Example:
Say i wanted to add a line to an INI file like (eg) RUN=Welcome.exe into the win.ini file, and I wanted it to OVERWRITE the current RUN= line?
I'm sure someone will know what im getting at! Thanks!
Al



Report Offensive Message For Removal

Response Number 1
Name: Me again
Date: June 17, 2001 at 07:46:53 Pacific
Subject: Inserting text into files using some DOS
Reply: (edit)

PS-Sorry but i pasted the darn thing in twice(!) Ignore the top bit, the second one is the one i want you to read..
Thanks!


Report Offensive Follow Up For Removal

Response Number 2
Name: Dan Penny
Date: June 17, 2001 at 08:21:21 Pacific
Subject: Inserting text into files using some DOS
Reply: (edit)

I think the append command along with the pipe command, been a long time;
append welcome.exe | win.ini
or something along those lines. Sorry to be vague(sp?) on this but it might spark some memory cells. Rediirect > might be in there too.


Report Offensive Follow Up For Removal

Response Number 3
Name: jboy
Date: June 17, 2001 at 20:26:34 Pacific
Subject: Inserting text into files using some DOS
Reply: (edit)


This sounds very familiar...

copy con filename

then type your text (up to 127 chr), enter for a new line.

F6 or CTRL-Z to close

To append output to a file:

'command' >>filename
for example, if you wanted the help text for a command:

xcopy /? >help.txt
would create 'help.txt' with the screen output from 'xcopy /?'
If there already exists 'help.txt' - it will be overwritten!
xcopy /? >>help.txt
would 'append' or keep adding to the 'help.txt' file.
(You don't have to have a space between the redirect arrows and the target file, but you can if you want to)
xcopy /? >> help.txt
is ok too.
Is this what you're looking for?




Report Offensive Follow Up For Removal

Response Number 4
Name: Secret_Doom
Date: June 18, 2001 at 15:56:04 Pacific
Subject: Inserting text into files using some DOS
Reply: (edit)

Well, I think he was looking for something else.
Let me see if I've got it: you want the line to be automatically put into a file, overwriting the similar line that was there.
Here's how to do it.
I'll need EDLIN.EXE. You may get it here:
http://filebox.vt.edu/users/alrobin2/home/edlin/download.html
(dont be scared with the page)(put it in a directorypath, such as c:\windows)

It's a batch file. I will use the same example you did. The batch will also use a complementar file, also posted below.

----------------------------------------
----------------------------------------
contents of string.bat:

@echo off
find /n /i "RUN=" c:\file.ini> out.bat
edlin out.bat [lessthan] string.rep >nul
echo SET LINE=%%1> string2.bat
call out.bat
echo %line%> string2.rep
echo RUN=Welcome.exe>> string2.rep
echo e>> string2.rep
edlin c:\file.ini [lessthan] string2.rep >nul
del out.bat
del string2.bat
del string.rep

----------------------------------------
contents of string.rep:

1,#r[^Zcall string2.bat,
1,#r]^Z,
e

----------------------------------------
----------------------------------------

NOTE1: ^Z means CTRL+Z character. You may get it at dos edit by CTRL+P+Z
NOTE2: [lessthan] means the lessthan character (the opposite of ">"). This forum has problems in posting it....

That's it. Any further questions, mailme.
I have sent this to your email also.

-- Secret_Doom --

email: secret_doom@hotmail.com


Report Offensive Follow Up For Removal

Response Number 5
Name: Secret_Doom
Date: June 18, 2001 at 16:13:42 Pacific
Subject: Inserting text into files using some DOS
Reply: (edit)

OOOOOOOPS!
I have made a mistake. The string.bat from last post is wrong. This one is right:

@echo off
type file.ini |find /n /i "RUN=" > out.bat
edlin out.bat [lessthan] string.rep >nul
echo SET LINE=%%1> string2.bat
call out.bat
echo %line%> string2.rep
echo RUN=Welcome.exe>> string2.rep
echo e>> string2.rep
edlin file.ini [lessthan] string2.rep >nul
del out.bat
del string2.bat
del string2.rep
del out.bak
del file.bak

Now it's ok and well tested!
sorry


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Inserting text into files using some DOS

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software