Bat file to delete first three lines in text file

Posted on 2007-10-09
Last Modified: 2012-06-27
Hey guys,

I need a script that will delete the first three lines from a text files.

All help is greatly appreciated.

Question by:chetan1981
    LVL 16

    Assisted Solution

    by:Brian Pringle
    LVL 82

    Accepted Solution

    Try this (will remove empty lines on its way; if it needs to keep empty lines, say so); input file and output file could ba passed in the command line as well:

    @echo off
    set InputFile=in.txt
    set OutputFile=out.txt
    if exist "%OutputFile%" del "%OutputFile%"
    for /f "skip=3 delims=" %%a in ('type "%InputFile%"') do >>"%OutputFile%" echo %%a

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
    TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now