|
Answer» How do i delete the line from the file ?
For example i have file .If i run the for loop first time the first line of the file should be deleted.If run second time it has to delete the second line ETC .could you please help me to do it? You never mentioned your OS this but may work:
Code: [Select]@echo off setlocal enabledelayedexpansion SET count=0 for /f "tokens=* delims=" %%i in (data.txt) do ( set /a count=%count%+1 if not !count!==1 echo %%i >> data1.txt )
Text files do not allow in-place deletes; you MUST create a SEPARATE output file.
8-)
Quatroking has a point. Run this enough times and you'll run out of lines to delete. Quote How do i delete the line from the file ?
For example i have file .If i run the for loop first time the first line of the file should be deleted.If run second time it has to delete the second line etc .could you please help me to do it?
can you provide a use case for this? from what i see, it SEEMS your intention is to delete all the lines of the file? if it is, just Code: [Select] type nul > yourfile.txt will do. This will blank out your file. I may be wrong though
|