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

The Archive Base Latest Questions

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

I need to execute a command 100-200 times, and so far my research indicates

  • 0

I need to execute a command 100-200 times, and so far my research indicates that I would either have to copy/paste 100 copies of this command, OR use a for loop, but the for loop expects a list of items, hence I would need 200 files to operate on, or a list of 200 items, defeating the point.

I would rather not have to write a C program and go through the length of documenting why I had to write another program to execute my program for test purposes. Modification of my program itself is also not an option.

So, given a command, a, how would I execute it N times via a batch script?

Note: I don’t want an infinite loop

For example, here is what it would look like in Javascript:

var i;
for (i = 0; i < 100; i++) {
  console.log( i );
} 

What would it look like in a batch script running on Windows?

  • 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-14T04:43:20+00:00Added an answer on May 14, 2026 at 4:43 am

    for /l is your friend:

    for /l %x in (1, 1, 100) do echo %x
    

    Starts at 1, increments by one, and finishes at 100.

    WARNING: Use %% instead of %, if it’s in a batch file, like:

    for /l %%x in (1, 1, 100) do echo %%x
    

    (which is one of the things I really really hate about windows scripting.)

    If you have multiple commands for each iteration of the loop, do this:

    for /l %x in (1, 1, 100) do (
       echo %x
       copy %x.txt z:\whatever\etc
    )
    

    or in a batch file:

    for /l %%x in (1, 1, 100) do (
       echo %%x
       copy %%x.txt z:\whatever\etc
    )
    

    Key:

    • /l denotes that the for command will operate in a numerical fashion, rather than operating on a set of files
    • %x is the loops variable and will be (starting value, increment of value, end condition[inclusive] )
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to execute MDX query from command line (MS AS 2005). I have
I have any number of anchor links on a page that need to execute
I need to execute a directory copy upon a user action, but the directories
I need to execute a command per line of some file. For example: file1.txt
I'm developping my first Android App. I need to execute a command in a
I would like to know how to execute a system command from an android
I need to execute this Sql command (which works fine in management studio): select
I have to execute this command with given username; in bash it'd be, $su
I need to execute a large set of SQL statements (creating a bunch of
I need to execute a select and then update some of the rows in

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.