Windows – download a series of files automatically using command line/wget

command linedownloadwgetwindows

I have a case that I would like to trigger an automatic download for a list of 114 file (recitation) for each reader,
for example if i want to download the recitations for a reader called abkr, the urls for the files will look like the following..

http://server6.mp3quran.net/abkr/001.mp3
http://server6.mp3quran.net/abkr/002.mp3
...
http://server6.mp3quran.net/abkr/113.mp3
http://server6.mp3quran.net/abkr/114.mp3

simply these are Quran recitations, so they are always have a total of 114

is there an easy way to loop that using command line on Windows ?

Best Answer

For the sake of completeness, here's a batch-only solution:

@ECHO OFF
SetLocal EnableDelayedExpansion
FOR /L %%G IN (1, 1, 114) DO (
    SET num=%%G
    IF 1!num! LSS 100 SET num=0!num!
    IF 1!num! LSS 200 SET num=0!num!
    wget http://server6.mp3quran.net/abkr/!num!.mp3
)
EndLocal

Edit 1: Removed unnecessary braces.

Edit 2: Corrected counter start value to 1.

Related Question