Reputation: 476
What's wrong with this script?
@echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set /P start= Input start : %=%
set /P end= Input End : %=%
for /l %%i IN (%start%,1,%end%) DO (
set num=0%%i
set num=!num:~-2!
echo wget "http://portal/excel!num!.xls"
)
pause
if Input start = 01
, Input End = 06
, work fine and excel files downloaded. Result :
Input start : 01
Input End : 12
wget "http://portal/excel01.xls"
wget "http://portal/excel02.xls"
wget "http://portal/excel03.xls"
wget "http://portal/excel04.xls"
wget "http://portal/excel05.xls"
wget "http://portal/excel06.xls"
wget "http://portal/excel07.xls"
wget "http://portal/excel08.xls"
wget "http://portal/excel09.xls"
wget "http://portal/excel10.xls"
Press any key to continue . . .
But if Input start = 01
, Input End = 08
OR
if Input start = 01
, Input End = 09
, Not work fine and excel files not downloaded. Result :
Input start : 01
Input End : 08
Press any key to continue . . .
Can anyone give some explanations?
Upvotes: 0
Views: 106
Reputation: 41234
This is a workaround:
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set start=101
set end=199
for /l %%i IN (%start%,1,%end%) DO (
set num=!num:~-2!
echo wget "http://portal/excel!num!.xls"
)
Upvotes: 2
Reputation: 4750
Leading zero means number is intepreted as octal. 0-7 don't matter, but there is no such number as an octal 8 or 9. You are already adding a leading 0 with the 2 SET commands, so don't enter the leading zero.
Upvotes: 3