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

  • Home
  • SEARCH
  • 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 9014357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:29:16+00:00 2026-06-16T03:29:16+00:00

I am new to windows batch scripting and am having trouble extracting information from

  • 0

I am new to windows batch scripting and am having trouble extracting information from a text file. My script needs to iterate over a text file with an unknown number of lines and search for the string “Installer ID:”. Once this is found I need to store whatever information is on the right hand side of the colon.

For example if my text file looked as follows:

SomeText.txt
------------------------
Installer Date: 2010_10_24_24345
OXF BUILD ID: OXF-12223
Installer ID: OTFI-316
Excel  ID: 2-10186
BUILD DBID: 296414
Version: 6.2

I would want to store:

OTFI-316

I have come so far with something like this:

@echo off
setlocal EnableDelayedExpansion
set file=build_info.txt
FOR /F "tokens=*" %%i IN (%file%) DO (
findstr Installer ID: %%i
if %errorlevel%==0 (
set installer_id=SUBSTRING I
)  

but I am having problems searching %%i for “Installer ID:” with its two words and colon, and from there I am unsure how to properly substring %%i.

  • 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-16T03:29:17+00:00Added an answer on June 16, 2026 at 3:29 am

    Put the FINDSTR command within the FOR IN() clause, and parse the results.

    I set DELIMS to colon and space so that all of the following lines would give the correct result:

    Installer ID: OTFI-316
    Installer ID:OTFI-316
    Installer ID:      OTFI-316
    

    You want everything after the 2nd token (the * in tokens=2*).

    @echo off
    set "file=build_info.txt"
    set "installer_id="
    for /f "tokens=2* delims=: " %%A in (
      'findstr /bc:"Installer ID:" "%file%"'
    ) do set "installer_id=%%B"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I already know how to create a new cmd window from a batch script
I'm creating a batch file (on Windows Vista) to deploy my project from development
I'm trying to map network drive from windows service, I use batch file for
I am completeley new with windows batch scripting. I want to write a batch
I'm new to Windows batch files, but I'm writing a .bat file that just
I am in the process of moving some sites over to a new windows
I'm attempting to rewrite a configuration file using a Windows Batch file. I'm looping
I'm trying to create a simple script in batch to run in Windows, the
I'm new to Python. I'm trying to run this script (gencards.py) in Windows, but
I have two .exe file and 3 windows batch files and i need to

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.