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


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 ?

  • Which operating system?
    – Indrek
    Commented Sep 3, 2012 at 13:16
  • Windows is preferred, Mac is Ok as well.. Commented Sep 3, 2012 at 14:18

4 Answers 4


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

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

Edit 1: Removed unnecessary braces.

Edit 2: Corrected counter start value to 1.

  • all solutions are great, but I'm gonna accept this since it is straight forward (command-prompt), and does not require something other than wget.. Commented Sep 5, 2012 at 5:31
  • a small correction, the loop starts from 1 instead of 0. Commented Sep 5, 2012 at 5:32
  • Oops, correcting...
    – zb226
    Commented Sep 5, 2012 at 8:09

You haven't stated OS, but if you are using *nix and Bash the following works:

wget http://server6.mp3quran.net/abkr/{001..114}.mp3

A solution that should work with any shell:

for i in $(seq -w 1 114); do
    printf 'http://server6.mp3quran.net/abkr/%s.mp3 ' $i
done | xargs wget

or, if seq does not exist on the system:

while [ $i -le $MAX ]; do
    printf 'http://server6.mp3quran.net/abkr/%03d.mp3 ' $i
done | xargs wget

Just copy+paste it in the shell or save it in a script file and run it.

  • is Mac OSX included in your *nix solution ? Commented Sep 4, 2012 at 4:15
  • anasnakawa: Yes, you can run Bash on MacOSX, but it is not the default shell, I believe. Try just running the command "bash" in a terminal. You might need to install it beforehand, or look for a simple solution using the default shell. To clarify: the above will definitely work, but it might not be the most obvious way if Bash is not already installed. Commented Sep 4, 2012 at 8:33

For a Windows solution, try the following PowerShell script:

$Client = New-Object System.Net.WebClient
for ($i = 1; $i -le 144; $i++)
    $file = [string]::Format("{0:D3}.mp3", $i)
    $Client.DownloadFile("http://server6.mp3quran.net/abkr/" + $file, $file)

First cd into the directory you want to download the files to, of course.


For reference and the sake of completeness a version without seq, a nice output and continue if the download stops for whatever reason:

for i in 00{1..9} 0{10..99} {100..144}; do
    printf 'http://server6.mp3quran.net/abkr/%03d.mp3 ' $i
done | xargs wget -q --show-progress -c

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .