Solved

Batch variable increment

Posted on 2001-06-11
3
6,230 Views
Last Modified: 2013-12-28
Is it possible to increment a variable by 1 in a batch file? (Winnt 4.0).  For example, if COUNT is currently 100000, increment COUNT to be 100001.

Thanks.
0
Comment
Question by:j_k
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Expert Comment

by:jjeff1
ID: 6179467
http://www.zdnet.com/pcmag/issues/1511/pcmg0088.htm

Hows that? It will take a bit of tweaking, but should work for you.
0
 
LVL 3

Accepted Solution

by:
czpczp earned 50 total points
ID: 6181046
Hi j_k.  The easiest way to do this is to use the SET and For statements in tandem.  There's many things you can do here.  Based on the information you provided, this batch will increment the variable Count (who's value is 100000) by 1.  If you wanted to count up to we'll say 100050 then in the For statement, change (1,1,1) to (1,1,50) and so on.


@echo off
cls

Set /a Count=100000
for /L %%i IN (1,1,1) DO set /a Count=%Count% + %%i
echo %Count%



Like I said, there's many things you can do here (and many ways to accomplish this).  To simply increment by one you can use:


Set /a Count=100000
.
.   The next Set statement could appear later in a batch
.
Set /a Count=%Count% + 1



If you need further info, please provide feedback.
0
 

Author Comment

by:j_k
ID: 6181419
Just what I needed.  Thanks.
0

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configuring Remote Assistance for use with SCCM
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question