Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batch download images from url with for

Tags:

batch-file

cmd

I need to download 300 images from site.com/folder/ using the following format: 1.png, 2.png ... 300.png

Is there a way to do this inside a batch file or using the command prompt?

like image 934
EvaldasL Avatar asked Dec 13 '22 21:12

EvaldasL


2 Answers

Wth curl like this:

curl -o "#1.png" http://example.com/folder/[1-300].png
like image 136
Mark Setchell Avatar answered Dec 16 '22 11:12

Mark Setchell


Here is an example to download some batch codes from a file that can be created by this script if not exist, and of course you can add or modify what you want of urls in this file !

You can add your urls in the text file named Urls.txt

Firstly, the script check for the text file named Urls.txt if exist in same location where this batch is executed and read from it the urls line by line to download them ! So, if you want to change those urls to yours, just change it from the text file Urls.txt not from the batch, i mean you can create a text file and name it to Urls.txt and put what you want as urls on this file line by line of course and let the script do its job

@echo off
Mode 110,3 & color 0A
Title Download file from web using powershell and batch by Hackoo 2017
Set "List_Urls_File=Urls.txt"
If not exist "%List_Urls_File%" Call :Create_Urls_File
Setlocal enabledelayedexpansion
@For /f "delims=" %%a in ('Type "%List_Urls_File%"') do (
    Set "URL=%%a"
    Rem we set the Filename from the variable !url!
    @for %%# in (!url!) do ( set "File=%%~xn#" )
    Rem Check if the file name contains a dot "." 
    Rem If not we increment the counter +1 for file to be download
        ECHO !File! | FIND /I ".">Nul 2>&1
        If "!errorlevel!" NEQ "0" (
            Set /a Count+=1
            cls & echo(
            echo               Downloading file "File-!Count!.bat" from URL : "!URL!"
            Call :BalloonTip 'information' 10 '"Downloading File-!Count!.bat"' "'Please wait... Downloading File-!Count!.bat....'" 'info' 4
            Call :Download "%%a" "File-!Count!.bat"
        ) else (
            cls & echo(
            echo    Downloading file "!File!" from URL : "!URL!"
            Call :BalloonTip 'information' 10 '"Downloading !File!"' "'Please wait... Downloading !File!....'" 'info' 4

            Call :Download "%%a" "!File!"
        )
)
Explorer "%~dp0" & exit
::*********************************************************************************
:Download <url> <File>
Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%1','%2')"
exit /b
::*********************************************************************************
:Create_Urls_File
(
    echo https://pastebin.com/raw/XvyhRzT6
    echo https://pastebin.com/raw/QqnZ0MjQ
    echo https://pastebin.com/raw/tHsKw15V
    echo https://pastebin.com/raw/VCnTbLB6
    echo https://pastebin.com/raw/3zUTrWUz
    echo https://pastebin.com/raw/31auQeFz
    echo https://pastebin.com/raw/xF0uXThH
    echo https://pastebin.com/raw/uzsGQD1h
    echo https://pastebin.com/raw/3TmVYiZJ
    echo https://pastebin.com/raw/Ntc8SZLU
    echo https://pastebin.com/raw/jnpRBhwn
    echo https://www.virustotal.com/static/bin/vtuploader2.2.exe
    echo http://devbuilds.kaspersky-labs.com/devbuilds/KVRT/latest/full/KVRT.exe
)>"%List_Urls_File%"
exit /b
::*********************************************************************************
:BalloonTip $notifyicon $time $title $text $icon $Timeout
PowerShell  ^
  [reflection.assembly]::loadwithpartialname('System.Windows.Forms') ^| Out-Null; ^
 [reflection.assembly]::loadwithpartialname('System.Drawing') ^| Out-Null; ^
 $notify = new-object system.windows.forms.notifyicon; ^
  $notify.icon = [System.Drawing.SystemIcons]::%1; ^
  $notify.visible = $true; ^
  $notify.showballoontip(%2,%3,%4,%5); ^
  Start-Sleep -s %6; ^
  $notify.Dispose()
%End PowerShell%
exit /B
::*************************************************************************
like image 24
Hackoo Avatar answered Dec 16 '22 11:12

Hackoo