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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:34:23+00:00 2026-06-10T22:34:23+00:00

I am using windows , and I want to do a loop inside a

  • 0

I am using windows , and I want to do a loop inside a bat and to break it when a condition is satisfied , and I dont want to use goto , can some one give me the general way to do it ?
in my case , I want to loop until a file size is bigger than 200 KB , so in my batch I create a file (that’s get bigger with time) , then I want to check it size with loop
if it greater than 200 KB I want to break loop

  • 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-10T22:34:25+00:00Added an answer on June 10, 2026 at 10:34 pm

    Unfortunately the batch scripting language doesn’t have while loops, only for loops with a predetermined amount of iterations, so I’m afraid that if+goto is your only option. Why are you determined to avoid goto statements in batch?

    The following code resembles a common do-while loop:

    :do_while_loop_start
    rem This is the body of the loop (do something here...)
    
    :do_while_loop_end
    for /f "usebackq" %%a in ('somefile.txt') do set filesize=%%~za
    if %filesize% leq 204800 goto do_while_loop_start
    

    Isn’t it elegant enough? I think it is.

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

Sidebar

Related Questions

I want to FTP some files across networks using Windows FTP command prompt and
I'm using Windows XP Pro SP3. I want to use SSPI functions in my
I'm new windows phone, I want to create a textbox one by one inside
I'm using windows 7 64 bits and I want to know if I need
Using Windows form (Vb.net & Datagridview) Checkbox is using in datagridview row. I want
I want to provide my colleagues with an interface (using Windows Forms or WPF)
I am using windows 2000 server. I want to know top 5 processes that
new on ruby and using windows xp and rails 3, i want to send
we are using Windows Server 2008 R2 O/S. We want to execute an script
If I am using Windows Authentication in an ASP.NET app, and I want to

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.