Delete Line Using Batch File
|
Original Message
|
Name: Nath5
Date: November 23, 2007 at 21:57:30 Pacific
Subject: Delete Line Using Batch FileOS: Windows XpCPU/Ram: AMD Turion 64x2 2 Gig ramModel/Manufacturer: Hp |
Comment: I need to set the first line of a *.ini file to a variable and then delete it, and then look at the new first line set it and then delete it until there are no lines left. For example test.ini 2 60 "C:\documents and settings\me\desktop\p.txt" 40 "C:\documents and settings\me\desktop\q.txt" I would like to be able to set each line to its own variable but the only way I can think to do it is to delete each line after it is read in. I have looked at some examples of ways to read through a list but I was completely lost. Any help either with code to read through the list or delete each element is much appreciated. Thanks
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: Mechanix2Go
Date: November 24, 2007 at 05:21:08 Pacific
|
Reply: (edit)@echo off setLocal EnableDelayedExpansion for /f "tokens=* delims= " %%a in (my.ini) do ( set /a N+=1 set var!N!=%%a ) set v
===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: Nath5
Date: November 24, 2007 at 09:31:14 Pacific
|
Reply: (edit)Thanks so much that worked great but now i have another question. In the ini i have two groups of info 2 60 c:\... /min 45 c:\documents and settings\... /max The first line "2" tells the program how many groups there are. I am trying to figure out a way to get the first line and then use that to gather all the other information into variables. The problem is that i don't want to have to type out code or ever group, for example both lines that start with c:\ are applications that need to be started. I would like some way of saying start var2,var4,var6...varn+2 up until said var does not exist. Sorry is this is a confusing question again thanks for any help.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: Mechanix2Go
Date: November 25, 2007 at 00:44:08 Pacific
|
Reply: (edit)Hi tony, It shows all vars beginning with v. In this case, just to show that it worked. ================================== Nath5, Do you want to run every line whoch contains: "C:\documents and settings\me... ===================================== If at first you don't succeed, you're about average.M2
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: