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 to change lines in a file
Name: chestm Date: March 11, 2009 at 10:08:30 Pacific OS: Windows XP Subcategory: Batch
Comment:
i would like to create a file that preforms 2 operations: 1. finds an line in a file goes one line above that and inserts a line and a string statement. i.e.
find line paul above line paul insert Apple
and 2. changes certain lines in a file to another line. For instance: Said file has 100 lines for lines 30 - 80 change john to jason if john is present in that line. for lines 30 - 80 change amy to angie if amy is present in that line.
lines 30 - 80may change per file with variable key words is there a way to input that key word?
I would like to do this as a batch file but I've also been recomended to use perl. whichever will be easiest to implement is what I'd like to do. any help in this matter would be most appreciated.
Name: Holla Date: March 11, 2009 at 10:16:16 Pacific
Reply:
for /? Is this a classroom assignment?
-- Holla.
0
Response Number 2
Name: chestm Date: March 11, 2009 at 10:23:22 Pacific
Reply:
No this is for at work and the information is sensitive so I can't go into an actual file description; however I hope this is sufficient.
0
Response Number 3
Name: Holla Date: March 12, 2009 at 02:15:50 Pacific
Reply:
Untested: i am only providing general flow.
setlocal EnableDelayedExpansion
set linecount=1
for /f "tokens=*" %%a in (inputfile.txt) do (
set ReadLine=%%a
if ReadLine=paul echo Apple >> OutputFile.txt
if !linecount! leq 30 (
set Outline=!ReadLine:john=Jason!
) else if !linecount! leq 80 (
set Outline=!ReadLine:amy=angie!
)
set /a varcount+=1
>>OutputFile.txt echo !Outline!
)
Summary: was wondering if you could help me with a script to remove ALL the lines in a file that contain the word "BOUNDARY". I have the script like this so far, but It will only remove the first occurance of...
Summary: I’m trying to making a batch file that replaces a word with another in a file(s!) that containing the word. By using Edlin program. And to use edlin so req. it ^Z (Ctrl+Z) as a breaker between old t...
Summary: I have to match a particular set of line in a file using certain condition wic i hav written but instead of copy paste the matched lines into a new file we will need cut and paste it :)) ...