Open website url links with parameter by using a batch file

时光怂恿深爱的人放手 提交于 2019-12-25 04:44:11

问题


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)


回答1:


For /L %%i in (1000,1,5000) do (
     start "images" "www.images.com/%%i/image.jpg" 
)



回答2:


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



来源:https://stackoverflow.com/questions/30872951/open-website-url-links-with-parameter-by-using-a-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!