Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8750613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:53:52+00:00 2026-06-13T12:53:52+00:00

I have a large(20MB) text (input) file with various lines of text (including blank

  • 0

I have a large(20MB) text (input) file with various lines of text (including blank lines) in it. I would like a batch file that can find specific text in the input file, grab the string the search term is in, write that string to another text (output) file AND append that string with a space, comma and the line that follows it in the input file in the output file.

  1. INPUT FILE DATA:

    NORTHING         EASTING   O-HEIGHT     CODE FFF STATION   STD DEV MAPPROJ 
    

    NEO 000 020720618 4829559.470 ,12082011c.lst

    0.015 0.015 0.015
    NEO 000 020740188 4835430.827 ,12082011c.lst

    0.009 0.009 0.009
    NEO 000 020750232 4841535.651 ,12082011c.lst

    0.004 0.004 0.004
    PLH 000 020720615 N 43 36 15.44568 W 79 32 38.22754 67.892 m 0 ,12082011c.lst

    0.014 0.014 0.014 ,12082011c.lst

  2. SEARCH TERM: “NEO”

  3. OUTPUT:

    NEO 000 020720618 4829559.470 ,12082011c.lst, 0.015 0.015 0.015
    NEO 000 020740188 4835430.827 ,12082011c.lst, 0.009 0.009 0.009
    NEO 000 020750232 4841535.651 ,12082011c.lst, 0.004 0.004 0.004

I’ve tried using the findstr command and it will write the first part of the line ( NEO 000 020720618 4829559.470 ,12082011c.lst) but I can’t figure out how to grab the next line and append it to the string. (the strings are longer than I’ve shown in this example so if there is a character limit for variables please let me know).
Thanks,
Gabe.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T12:53:53+00:00Added an answer on June 13, 2026 at 12:53 pm

    As I indicated in my comment, batch is not a good choice for processing text files. But here is a native batch solution for your problem. I am assuming you are searching for lines where the first token is NEO, not for lines that contain NEO anywhere within.

    It looks like you want to ignore the empty lines, which is good because FOR /F ignores empty lines.

    This solution will also ignore any line that begins with ; due to the default FOR /F EOL option. This can be eliminated by setting EOL to a linefeed character, but the syntax is ugly. I am assuming you do not have lines that begin with ;.

    As with any batch solution, lines are limited to ~8191 bytes.

    @echo off
    setlocal disableDelayedExpansion
    set "ln1="
    >"output.txt" (
      for /f "useback delims=" %%A in ("input.txt") do (
        if defined ln1 (
          set "ln2=%%A"
          setlocal enableDelayedExpansion
          echo(!ln1! ,!ln2!
          endlocal
          set "ln1="
        )
        for /f %%B in ("%%A") do if "%%B"=="NEO" set "ln1=%%A"
      )
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large report file (about 20MB) that looks like this: 586 700006207
i have large numbers of text files and i am in problem that i
I have large images displayed in a grouped tableview. I would like the images
I have a large data file, which is zipped, and approximately 20MB. When it's
I have large file comprising ~100,000 lines. Each line corresponds to a cluster and
I have a C# app that needs to add large amounts of text to
Parsing a 20MB file that is too large to do in one piece on
I have large main file contains about 7,000 lines of C code. If I
I have large number of files with .gif extension. I would like to move
I have large video files (~100GB) that are local on my machine. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.