Counting in batch files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
haste
Posts: 1
Joined: 24 Apr 2018 04:45

Counting in batch files

#1 Post by haste » 24 Apr 2018 04:51

Hi guys,

I'm a beginner, so please bare with me. I want to count in a loop. This works fine. I use this code:

Code: Select all

for /l %%a in (1,1,100) do (
	curl "https://www.justadomain.com/500%%a" -o "500%%a.html"
	timeout 5 > NUL
)
I'm fetching the pages 5001 until 5009 correctly, but after that it starts going to 50010, 50011, 50012, etc.
How can I start my counting with 001 and increase this with 1 (002, 003, 004)?

Thanks in advance!
Haste

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Counting in batch files

#2 Post by Squashman » 24 Apr 2018 07:51

Code: Select all

for /l %%a in (5001,1,5100) do (
	curl "https://www.justadomain.com/%%a" -o "%%a.html"
	timeout 5 > NUL
)

Post Reply