Searching a way to download something via cmd or bat

Discussion in 'Scripting' started by ege914, Jan 20, 2021.

  1. ege914

    ege914 MDL Senior Member

    Jun 29, 2015
    257
    47
    10
    #1 ege914, Jan 20, 2021
    Last edited: Jan 20, 2021
    Hello, I am trying to download something via cmd or bat script.. The problem is i don't know how to download it since its version name keeps changing in the link...

    http://www.hibitsoft.ir/HiBitUninstaller/HiBitUninstaller-Portable-2.5.90.zip

    if link were static i could use this, but with dynamic link like that i need a wildcarded command? i need some kind of pattern maybe..

    bitsadmin /transfer myDownloadJob /download /priority normal https://www.xxxxx.com/xxx %cd%\xxx > nul
     
  2. Tux 528

    Tux 528 MDL Novice

    Apr 20, 2020
    10
    11
    0
    Hi!

    To download this file, you can use this Batch script:
    Code:
    @ECHO OFF
    ECHO Downloading webpage of HiBit Uninstaller...
    PowerShell.exe -NoProfile -Command "(New-Object System.Net.WebClient).DownloadFile('https://www.hibitsoft.ir/Uninstaller.html', \"%TEMP%\HiBit Uninstaller.txt\")"
    ECHO Parsing downloaded HTML file...
    FOR /F "tokens=4" %%L IN ('FINDSTR /I /C:"Latest version:" "%TEMP%\HiBit Uninstaller.txt"') DO SET "version=%%L"
    TIMEOUT /T 1 /NOBREAK > NUL
    ECHO Current version of HiBit Uninstaller: %version%
    TIMEOUT /T 1 /NOBREAK > NUL
    ECHO Downloading HiBit Uninstaller %version%... Please wait.
    PowerShell.exe -NoProfile -Command "(New-Object System.Net.WebClient).DownloadFile('https://www.hibitsoft.ir/HiBitUninstaller/HiBitUninstaller-Portable-%version%.zip', \"%~dp0\HiBitUninstaller-Portable-2.5.95.zip\")"
    ECHO The installation program of HiBit Uninstaller has been successfully downloaded to the current directory.
    ECHO Press any key to exit this script...
    pause > NUL
    EXIT
    The used method is downloading the main webpage of the software with PowerShell and parsing it to get the version number. Then, all that is left to do is downloading the file by adding the version number to the download link. :)

    Happy computing!

    Best regards
     
  3. Tiger-1

    Tiger-1 MDL Guru

    Oct 18, 2014
    6,203
    7,532
    210
    hmm if you are using Firefox just click here
    http://www.hibitsoft.ir/HiBitUninstaller/HiBitUninstaller-Portable-2.5.90.zip and the file will be saved in your downloads folder so open with 7zip
     
  4. ege914

    ege914 MDL Senior Member

    Jun 29, 2015
    257
    47
    10
    #4 ege914, Mar 11, 2021
    Last edited: Mar 11, 2021
    (OP)

    changing the version number simply is the only thing i am trying to avoid. i am trying to make this automated.

    really man?


    thx guys i made it happen via aria2.exe tool