0

このスクリプトの何が問題になっていますか?

@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

の場合Input start = 01Input End = 06正常に動作し、Excel ファイルがダウンロードされます。結果 :

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 . . .

しかし、場合Input start = 01Input End = 08または場合Input start = 01、、Input End = 09正常に動作せず、Excel ファイルがダウンロードされません。結果 :

Input start : 01
Input End : 08
Press any key to continue . . .

誰でも説明できますか?

4

2 に答える 2

3

先行ゼロは、数値が 8 進数として解釈されることを意味します。0 ~ 7 は問題ではありませんが、8 進数の 8 や 9 のような数字はありません。すでに 2 つの SET コマンドで先行 0 を追加しているため、先行ゼロを入力しないでください。

于 2013-08-28T02:53:43.353 に答える
2

これは回避策です:

@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"
)
于 2013-08-28T07:55:45.483 に答える