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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:08:52+00:00 2026-05-13T14:08:52+00:00

This is my code so far: for /f tokens=1 eol=, %%f IN (1,2,3,4) do

  • 0

This is my code so far:

for /f "tokens=1 eol=," %%f IN ("1,2,3,4") do  (
    echo .
    echo %%f    
)

I’m expecting that to produce:

.
1
.
2
.

etc…

But instead I get:

.
1

And that’s it. What am I missing?

  • 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-13T14:08:52+00:00Added an answer on May 13, 2026 at 2:08 pm

    You’ve misunderstood the options.

    • tokens=1 means you only want the first token on each line. You want all of the tokens on the line.
    • eol=, means you want to interpret a comma as the beginning of an end of line comment. You want to use delims=, instead to indicate the comma is the delimiter (instead of the default value of whitespace).

    FOR /F is primarily for operating on lines in a file. You’re not doing that. You’re operating on a single string, so Rubens’ answer is closer to what you want:

    @ECHO OFF
    SET test=1,2,3,4
    FOR /D %%F IN (%test%) DO (
      ECHO .
      ECHO %%F
    )
    

    However, in theory, you should be able to say something like:

    FOR /F "usebackq delims=, tokens=1-4" %%f IN ('1^,2^,3^,4') DO (
      ECHO .
      ECHO %%f    
      ECHO .
      ECHO %%g
      ECHO .
      ECHO %%h
      ECHO .
      ECHO %%i
    )
    

    This works as well, but probably doesn’t scale in the way you want. Note that you have to escape the comma in the string using the ^ character, and you have to specify the tokens you want and then use the subsequent variables %g, %h and %i to get them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code so far which perfectly but relies on there being a
As far as I can tell, this code is fine, and should display some
This is what I have as far as code, it is in the first
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
This code run on Turbo C but not on gcc compiler Error:syntax error before
So far I have tried using 'setParseAction' to get the location of matched tokens,
At the following first line of code I get this error: cannot convert ‘std::string’
This code in JS gives me a popup saying i think null is a
This code is from Prototype.js . I've looked at probably 20 different tutorials, and
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new

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.