Computing.Net > Forums > Programming > Delete Line Using Batch 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.

Delete Line Using Batch File

Reply to Message Icon

Name: Nath5
Date: November 23, 2007 at 21:57:30 Pacific
OS: Windows Xp
CPU/Ram: AMD Turion 64x2 2 Gig ram
Product: 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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: November 24, 2007 at 05:21:08 Pacific
Reply:

@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



0

Response Number 2
Name: Nath5
Date: November 24, 2007 at 09:31:14 Pacific
Reply:

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.


0

Response Number 3
Name: tonysathre
Date: November 24, 2007 at 20:12:51 Pacific
Reply:

M2, what does the set v command do.

"Computer security." — Oxymoron


0

Response Number 4
Name: Mechanix2Go
Date: November 25, 2007 at 00:44:08 Pacific
Reply:

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



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


C Get single Char visual studio 2005



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Delete Line Using Batch File

Deleting lines with batch files www.computing.net/answers/programming/deleting-lines-with-batch-files/13330.html

New line using batch files in .txt www.computing.net/answers/programming/new-line-using-batch-files-in-txt/16946.html

Batch File To Delete Line www.computing.net/answers/programming/batch-file-to-delete-line/15539.html