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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:26:36+00:00 2026-06-09T15:26:36+00:00

I am attempting to create a batch for loop (Windows XP and newer command

  • 0

I am attempting to create a batch for loop (Windows XP and newer command prompts) that iterates through a string containing one or more asterisks. How can I do this? Here is an example:

@FOR %%A IN (A* B) DO @ECHO %%A

The expected output (what I am trying to get) is the following:

A*  
B

However, what I am actually getting with the command above is B and only B. For some reason, everything with an asterisk is being ignored by the loop. I have attempted escaping the asterisk with 1-4 carets (^), backslashes (\), percent signs (%), and other asterisks (*), all to no avail. Thanks in advance for illuminating me.

IN CASE YOU WANT MORE INFORMATION:

The purpose of this is to parse a path out of a list of space-separated partial paths. For example, I want to copy C:\Bar\A.txt, C:\Bar\B.txt, and C:\Bar\C*.txt to C:\Foo\ using the following approach:

@SET FILE_LIST=A B C*  
@FOR %%A IN (%FILE_LIST%) DO @COPY C:\Bar\%%A.txt C:\Foo\

If there is another alternative way to do this (preferably without typing each and every copy command since there are ~200 files, which is the same reason I don’t want to store the full path for every file), I would appreciate the help. Thanks again,

-Jeff

  • 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-09T15:26:37+00:00Added an answer on June 9, 2026 at 3:26 pm

    This may help:

    @echo off
    set "it=a*b .txt-b*.txt-c*.txt-d.txt"
    set /a i=0,fn=3
    :startLoop
    set /a i=i+1
    for /f "tokens=%i%delims=-" %%m in ("%it%") do echo %%m
    if %i% lss %fn% goto:startLoop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to create a batch file that runs an .exe, but kills
When attempting to create a new Ruby on Rails app in Windows the command
I am attempting to create a report, utilizing a matrix, that only displays columns
I'm attempting to create a single Controller class to handle all foreseeable surveys that
I'm attempting to Create a Job and Add a Batch using the Salesforce Bulk
I'm attempting create a spinning reload button, such as the one found in the
I'm attempting to create a Parcelable class in Android so that I can pass
I am attempting to create an inbound Mule endpoint that will receive Syslog messages
So I am attempting to create a search field that will filter contacts on
I'm attempting to create a ListView adapter that has multiple types of views. I'm

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.