Open website url links with parameter by using a b

2019-09-18 01:45发布

I am trying to open some website url links with a parameter in my browser. I made a batch file using this code :

@echo off


start "images" "www.images.com/1000/image.jpg"
start "images" "www.images.com/1001/image.jpg"
start "images" "www.images.com/1002/image.jpg"
...
...
start "images" "www.images.com/5000/image.jpg"

All I want is to create a For loop that will do that :

For (i=1000; i<5000 ; i++)
{
     start "images" "www.images.com/i/image.jpg" 
}

where "i" is a parameter of the website link. I am new in the batch file creation and I cannot figure out how to make it work. I tried this one but it did not work:

for i in {1000..5000} 
do
start "images" "www.images.com/$i/image.jpg"

This question is a first step. Then i want to save the images shown on this links, only if the links are valid (not dead like in 403, 404 errors)

2条回答
淡お忘
2楼-- · 2019-09-18 02:35
For /L %%i in (1000,1,5000) do (
     start "images" "www.images.com/%%i/image.jpg" 
)
查看更多
孤傲高冷的网名
3楼-- · 2019-09-18 02:36

You didn't even try using correct syntax, instead assuming that cmd is like bash. Yay.

What you're looking for can be found with help for:

for /l %%i in (1000,1,5000) do ...

I'm unsure how you even plan to proceed from here, though, as your current approach will not allow you to save images. Also opening 4000 tabs in your browser will likely be not fun either.

You may want to take a look at PowerShell where the whole task you described is trivial:

4000..5000 | % { [IO.File]::WriteAllBytes("H:\$_.png", (iwr www.images.com/$_/image.jpg).Content) }

And even without the need for external programs (e.g. wget or curl).

查看更多
登录 后发表回答