0

I have created a batch file after taking some advice from previous question :

Previous Question

After adding a time delay, the final script is the following :

@echo off

For /L %%i in (1000,1,1002) do 
(
     start "images" "www.images.com/%%i/image.jpg" 
     timeout 5 >nul
)

Now I want the website image links to be saved only if there is an image. If we get 403, 404 results or even a blank page, I don't want to get the result. That means that the code can be changed in order to save the file instead of opening the link in the browser.

Secondly, if I want to open 1000 links, it is going to take some time after having put the delay. Is there an option to make it faster without creating something like a d-dos attack thing? I mean, I do not want the server to be down because of my actions.

Community
  • 1
  • 1
Datacrawler
  • 2,780
  • 8
  • 46
  • 100
  • check this - http://stackoverflow.com/questions/28143160/how-can-i-download-a-file-with-batch-file-without-using-any-external-tools - as you have the link you'll need to download the image – npocmaka Jun 17 '15 at 09:53
  • Also, `powershell "ipmo BitsTransfer; Start-BitsTransfer %URL% 'd:\path\to\save\location'"`. Actually, there's no reason not to write the whole thing in powershell. `ipmo BitsTransfer; for ($i=1000; $i -le 1002; $i++) { Start-BitsTransfer "http://www.images.com/$i/image.jpg" "c:\path\to\save\location" }` would be more efficient than invoking a new instance of PowerShell for each iteration within a batch loop. – rojo Jun 17 '15 at 12:33
  • @rojo I will try doing that in a while. Should I leave my current code as it is though? Do you suggest me not opening the files by using the command "start"? – Datacrawler Jun 17 '15 at 12:52
  • If your goal is to display the images within the browser without saving, then `start` is a good way to go about it. If your goal is to download the images, the PowerShell `Start-BitsTransfer` cmdlet makes launching a web browser superfluous. – rojo Jun 17 '15 at 12:55
  • I added that : `ipmo BitsTransfer; for ($i=1439; $i -le 1441; $i++) {Start-BitsTransfer "http://images.adrivo.com/images/$i/0597753.jpg" "C:\Users\User\Desktop\images\" }` but it does not work. It does not save the images – Datacrawler Jun 17 '15 at 15:01
  • I mean. i made a powershell file (it is my first time). And I go to cmd and run the location of the .ps1 file. It just opens the file in notepad. Please give me a solution on that because I am curious. As far as concerned my main question, I would like the script to be in a batch file or programmed in C, C++ or JAVA. – Datacrawler Jun 17 '15 at 15:13

0 Answers0