Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is it possible to delete lines by their linenumbers only?

delete possible
0
Posted

Is it possible to delete lines by their linenumbers only?

0

You can determine the number of lines of a textfile by internal function @LINES[file], each individual line n by internal function @LINE[file,n], n starting with 0. So a batch to delete line n from a file would look like this: SET infile=%1 SET linetokill=%2 DO n=0 to %@dec[%linetokill] ECHO %@line[%infile,%n] >> outfile ENDDO DO n=%@inc[%linetokill] to %@lines[%infile] ECHO %@line[%infile,%n] >> outfile ENDDO DEL %infile REN outfile %infile This can be made quicker by using the @FILEOPEN, …READ, …WRITE, ..CLOSE functions, and by using SETDOS you can make it work with special characters (like those used for piping) too.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123