Help incrementing number with leading zeros - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help incrementing number with leading zeros

DJXDJX Posts: 1Member
Here is an example piece of code:
[code]
SET CurNum="1"
:Loop
ECHO "%CurNum%"
SET /A CurNum=%CurNum%+1
GOTO Loop
[/code]
My question is how would I incement that number with a set of leading zeros that would eventualy null out.

Say I want to have 6 leading zeros:
when it gets to 10, there will be 5 leading zeros, 100 there will be 4 leading zeros and so on.

Thanks for your help, I'm a little rusty on Batch. I have been working on VBScript lately.
Realisticly I'd like to have about 9 or 12 leading zeros...
Sign In or Register to comment.