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 6372485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:14:43+00:00 2026-05-25T01:14:43+00:00

I am reading through a file using a batch script. Basically I want to

  • 0

I am reading through a file using a batch script. Basically I want to read a specific line and set its tokens to different variables. The problem is, the line does not have a fixed number of tokens. Consider the following file format:

Line 1 Domains www.google.com www.yahoo.com www.reddit.com ...
Line 2 541 5435 322 123
Line 3 273 123 432 123

My script will be reading the line whose third token equals “Domains” and store the tokens that follow into different variables. In this case, I would set Domain1=www.google.com, Domain2=www.yahoo.com, Domain3=www.reddit.com, and so on. My code will look something like this:

for /f "tokens=3*" %%A in (%file%) do (
    if ("%%A"=="Domains") (
        REM Delimit %%B with a space and store each token into different variables
    )
)

EDIT: Problem solved. It is too soon for me to answer my own question due to insufficient rep, but here is my solution starting from Jeremy’s post:

set index=1
for /f "tokens=3*" %%A in (%file%) do (
    if ("%%A"=="Domains") (
        for %%C in (%%B) do (
            set Domain!index!=%%C
            set /A index+=1
        )
    )
)
  • 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-05-25T01:14:44+00:00Added an answer on May 25, 2026 at 1:14 am

    This doesn’t solve your problem exactly the way you wanted it solved but I think this is a workable solution:

    @echo off
    
    for /f "tokens=3*" %%A in (%file%) do (
      if "%%A"=="Domains" (
        set domains=%%B
      )
    )
    
    for %%A in (%domains%) do (
      echo %%A
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I'm reading through a file now, line by line. I know each functions
Possible Duplicate: Reading through file using ifstream I'm trying to find a way to
I've been reading through the details of the System libraries set and get methods
While reading a binary file using DJGPP on DOS this code hangs. This happens
I am reading through a directory with some pictures and such using a pretty
I've been reading through this tutorial for using a SQLite database within an iPhone
I'm initially building an index-like mechanism, read each line of the textfile using getline,
I usually loop through lines in a file using the following code: open my
I want to read a Open Office Document spreadsheet (.ods file) from my android
Reading through the Flickr API documentation it keeps stating I require an API key

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.