How to break out of for-loop using condition statement in batch file? -


I am processing a large number of files, and I found the files I am doing in the first 9. I tried this in a batch file and it does not work, it processes all the files, and does not stop at 9th place what have I done?

  setlocal set for file =% is doing in %% (* .doc) (works here ... set / single file + = 1 if "% fileCount < Code>   

The problem is that instead of the execution time of % filename% It is being expanded during pars-time, so it does not take into account the changes of fileCount during execution. So your for -loop is equivalent to: Do

  %% (* .doc) in (here) Rim the person ... set / one filename + = 1 if "0" == "9" exit)  

To fix this, you will be able to enable and delay You need to use instead of setlocal EnableDelayedExpension instead of setlocal , and instead of ! FileCount! % fileCount% < / Code>. Therefore:

  setlocal EnableDelayedExpension for set file %% i (* .doc) (Reef stuff is here ... set / single fileCount + = 1 "! FileCount! "= For more information, see. 


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -