Edit txt file by bat

1

I have the following problem: In a Windows directory, I have 3 .txt files that are automatically created every day. Inside them there are several lines with information. I want to delete two lines that are always repeated in all .txt and then save them without these two lines, continuing in the same directory.

Would you like to do this automatically with a .bat , script, or something that can be automated? If so, how can I do it?

    
asked by anonymous 13.07.2016 / 14:45

1 answer

1

So:

@echo off
setlocal enabledelayedexpansion

for %%x in (*.txt) do (
        call:skip "%%x"
        )
exit/b

:skip

set/a $c=1

(for /f "delims=" %%a in (%~1) do (
  if not !$c!==2 if not !$c!==4 echo %%a
  set /a $c+=1))>out.txt

move out.txt %1 2>nul
    
24.10.2016 / 00:45