As the title states I need a batch file to delete the FIRST 3 lines of a text file.
for example:
A
B
C
D
E
F
G
This should do it
for /f "skip=3 delims=*" %%a in (C:\file.txt) do (
echo %%a >>C:\newfile.txt
)
xcopy C:\newfile.txt C:\file.txt /y
del C:\newfile.txt /f /q
That will re-create the file with the first 3 lines removed.
To keep the user updated you could integrate messages in the batch file in vbscript style or output messages in the command prompt.
@echo off
echo Removing...
for /f "skip=3 delims=*" %%a in (C:\file.txt) do (
echo %%a >>C:\newfile.txt
) >nul
echo Lines removed, rebuilding file...
xcopy C:\newfile.txt C:\file.txt /y >nul
echo File rebuilt, removing temporary files
del C:\newfile.txt /f /q >nul
msg * Done!
exit >nul
Hope this helps.