Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to pick a line to work from. 2

Status
Not open for further replies.

lpblauen

Technical User
Dec 2, 2004
193
US
I haven't done this in years and forgot the way to do it. Its not really vb but I was hopeing someone could remember how its done.

I create a file lets call it count.txt in it its got 25 lines of whatever.

I can read the file using this command.
for /f %%X in (count.txt) do echo %%X

what I need to do is have the file read and say at line 10 pull that out set it as %%X and do something with that line then end.
So say its reading the file gets to line 10 pulls the line which is hello. then do print %%X and end. I would see Hello
Or if I said in my if statement its at line 20 which said goodbye once it got to line 20 it would do something then end.
The question is how to setup a loop to do something with a line number I set do something then end.
 
Did you read the result of the following command ?
for /?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
yes but how to do a /f and a /l together?

need to read a file /f and doing a /l to stop on a line number i set. I don't understand how to.
 
ok my batch program almost works. The problem is this now.

i get the line I want here it is.

for /f "skip=19" %%X in (c:\test\list.txt) do zip -r %%X.zip %%X

The problem is I need it to do one more thing before its done. After it creates the zip file I want it to remove the directory so I tried to add a second do to run but that fails.

for /f "skip=19" %%X in (c:\test\list.txt) do zip -r %%X.zip %%X : do rd %%X /s /q

The second do somehow gets piped into the zip command
I tryed this and that didn't help.

for /f "skip=19" %%X in (c:\test\list.txt) do (zip -r %%X.zip %%X) : do rd %%X /s /q

Ideas??
I dont think I'm using the right command separator symbol or something.
 
try:
[tt]for /f "skip=19" %%X in (c:\test\list.txt) do zip -r %%X.zip %%X && rd %%X /s /q[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top