erase line 2
before
1
2
3
4
5
-------------
after
1
3
4
5
Code: Select all
::not DELETE, but ERASE one line of your choice
@echo off &setlocal
rem set "file=%~1"
set "file=c:\a ! & bc.txt"
set /A DELETE=5
set /A KEEP1=DELETE-1
set /A KEEP2=DELETE+1
IF /I %DELETE%==0 GOTO :EOF
setlocal EnableDelayedExpansion
<"!file!" >"!file!.~tmp" (
for /f %%i in ('type "!file!"^|find /c /v ""') do (
for /L %%A in (1 1 %KEEP1%) do (
set "line1="& set /p "line1="
echo(!line1!
)
for /L %%A in (%DELETE% 1 %DELETE%) do (
set "line2="& set /p "line2="
echo(
)
for /L %%A in (%KEEP2% 1 %%i) do (
set "line3="& set /p "line3="
echo(!line3!
)
)
)
>nul move /y "!file!.~tmp" "!file!"
endlocal
how do i make the echo DELETE the line.
for /L %%A in (%DELETE% 1 %DELETE%) do (
set "line2="& set /p "line2="
echo(
DELETE line 2
before
1
2
3
4
5
----
after
1
3
4
5
question 2
set /A SKIP=4
for /l %%j in (1+SKIP 1 %%i) is ok
set /A DELETE=5
for /L %%A in (DELETE 1 DELETE) is not ok, why?
numerical number + string number isnt an error?
to save your time, i answered with few choices
1. that is just the way it is, accept it
2. doing it so has unknown benefits for heavy users
3. batch logic is a trash