?
Solved

Batch variable increment

Posted on 2001-06-11
3
Medium Priority
?
6,236 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 200 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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

Determining the an SCCM package name from the Package ID
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

752 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