Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to simplify the process of editing an .ini file for a proprietary software company. I know how to append text to a file which already exists but I was wondering if there was a way to specify the entry point of that text. Meaning, instead of simply adding to the end of the already existing text, directing it somewhere in the middle?

You can't do that directly. If you are using a batch script (note, by the way, this is not "DOS command" - there is no DOS in Windows 7, it's called the Win32 Command Processor and differs significantly from DOS) you will have to use a FOR /F statement to read the file line-by-line and write each line to a new file, until you get to where you want, then append the lines you want, then continue from where you left the file to add the remaining lines into the new file. Then delete the old file and rename the new one.
If you use a proper programming language, you can open the file in read+write mode, seek to the middle of the file, read and save the contents from there to the end, then seek back to the middle of the file, write the new content, and then write the saved content to the end.

Sorry for the confusion but this would be on a system running
Windows XP Pro SP2. I will look into the above mentioned for
/f statement but if there is a different way to approach this in
XP, please let me know. Thank you for all your help.

You need tobe clear about:
Does the original have blank lines?
Where is the new stuff to be inserted?
=====================================
Helping others achieve escape felicityM2

Here is where I need to be able to insert the text:
x= original text in file
xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
my new textxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxSorry for the confusion.

Again post this in the programming forum.
Its not specific enough. We need key words to mark where you want to start entering the text or at the very least the number of lines down.
To do this you could do some thing like...
@echo off set KeyText = "Bla" set TextToInsert = "Bla Bla Bla" echo y|del newfile.txt For /F "tokens=*" %%A in ('type yourfile.txt') do ( echo %%A >> newfile.txt if "%%A" == "%KeyText%" then echo %TextToInsert% >> newfile.txt )Reference:
http://commandwindows.com/batchfile...
http://www.robvanderwoude.com/ntfor...

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |