1

我正在尝试在 Windows 上使用 wget 从网络服务器下载 50 个 pdf。所有 pdf 都位于 www.abc.com/files/ 并且它们的 url 是 (www.abc.com/files/x.pdf, 其中 x = 1,2,3...50 )

我写的批处理脚本是

set "directory = http://www.abc.com/files/"
for %%x in (1, 1, 50) do (
        set pdfNum = %%x
    set "num = %directory%%pdfNum%"
        set "pdf = .pdf"
        set "file = %num%%pdf%"
    wget file
) 

但它似乎不起作用。帮助任何人。提前致谢....

4

2 回答 2

3
for /L %%x in (1,1,50) do (
        wget http://www.abc.com/files/%%x.pdf
) 

This code could help u.

于 2012-06-24T17:06:54.323 回答
2

you have some errors there... the way to do it is:

 setlocal enabledelayedexpansion
 @echo off
 set directory=courses.csail.mit.edu/6.006/spring11/lectures/lec/
 for /l %%x in (1, 1, 50) do (
    set pdfNum=%%x
    set num=%directory%!pdfNum!
    set pdf=.pdf
    set file=!num!%pdf%
    wget !file!
 )
  • you must not have spaces in the set param=value line
  • for /l iterates though the numbers

but i noticed that http://courses.csail.mit.edu/6.006/spring11/lectures/lec/1.pdf doesn't exist (i checked 1, 2, 3, 10 ... and i can't access them. besides that it works for me

于 2012-06-24T17:09:31.710 回答