[英]Using wget to get an excel files with FOR loop syntax on batch/CMD (*.bat) programing
请参阅我的问题使用批处理(* .bat)/ CMD中的FOR循环 。
我想使用wget获取Excel文件。
excel01.xls --> link : http://portal/excel01.xls
excel02.xls --> link : http://portal/excel02.xls
...
excel12.xls --> link : http://portal/excel12.xls
我的代码:
echo off
set /P start= Input start : %=%
set /P end= Input End : %=%
for /l %%i IN (%start%,1,%end%) DO echo wget "http://portal/excel0%%i.xls"
pause
结果:
Input start : 1
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/excel010.xls"
wget "http://portal/excel011.xls"
wget "http://portal/excel012.xls"
Press any key to continue . . .
正确的脚本如何导致第10-12行:
wget "http://portal/excel010.xls"
wget "http://portal/excel011.xls"
wget "http://portal/excel012.xls"
成为
wget "http://portal/excel10.xls"
wget "http://portal/excel11.xls"
wget "http://portal/excel12.xls"
对不起,我的英语说得不好。 :)
该脚本在数字前加上0
,然后获取最后两个字符。 我假设您不必担心数字> = 100。
@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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.