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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:53:04+00:00 2026-06-11T06:53:04+00:00

My code so far: for /F tokens=* %%A in (#opm.txt) do set str=%%A set

  • 0

My code so far:

for /F "tokens=*" %%A in (#opm.txt) do set str=%%A
set str=%str:~0,3%
@echo.%str% > #tags.txt

Basically, I have a huge list of things that I am attempting to take the first three letters from, however, I only end up getting one of those things from the list right now. For example:

The word ‘eagle’ is on the list. The end result should be EAG (and preferably in caps).

Any tips?

  • 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-11T06:53:05+00:00Added an answer on June 11, 2026 at 6:53 am

    If you want to do more than one statement in a for loop you need to use brackets:

    for /F "tokens=*" %%A in (#opm.txt) do ( 
        set str=%%A
        set str=%str:~0,3%
        @echo.%str% > #tags.txt
    )
    

    Note that opening bracket is in the same line as for … do … statement. In this case, you need to use delayed expansion to manipulate variables inside a loop (that makes variables enclosed with exclamation marks to be resolved in place):

    @setlocal ENABLEDELAYEDEXPANSION
    
    for /F "tokens=*" %%A in (#opm.txt) do ( 
        set str=%%A
        set str=!str:~0,3!
        @echo.!str! >> #tags.txt
    )
    
    @endlocal
    

    Please also note that redirection syntax was changed from > to >>. Single bracket redirection overwrites #tags.txt every times statement is executed. Double bracket redirection appends lines at the end of the file (you may want to assure that the file is empty before the loop).

    Replacing capitalization of a letters in batch is fairly complicated without external tools. This is not a text-processing-friendly technology. Have you considered Python instead?

    • 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
I have to following code and as far as I know it is correct,
I have an excel list (excel 2003) where user enter translations for tokens. It
Here is my code I have written thus far, along with the errors I'm
So far I have tried using 'setParseAction' to get the location of matched tokens,
I am going to start of by showing the code I have thus far:
Read the edit below for more information. I have some code below that I
So I have quite a dilemma. I have a code that reads a certain
I have a dictionary that searches for an ID name and reads tokens after
This is my code thus far: ArrayList<String> matches = data .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); String playString =

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.