
#!/bin/bash

good=0
bad=0
ugly=0
# Using ugly for skipped
for i in {0..100}; do 
  echo $i;
  dstr=$(date -d"Saturday $i weeks ago" +%y%m%d)
  file09="$dstr"0900h_robert_emmett.mp3
  file10="$dstr"1000h_robert_emmett.mp3
  file11="$dstr"1100h_robert_emmett.mp3
  for f in "$file09" "$file10" "$file11"; do
    wget_address="https://kfjc.org/archives/$f"
    if [ -f $f ]; then
      echo "$f exists"
      ugly=$(($ugly+1))
      echo "Skipping $f already there. Num Ugly=$ugly"
    else
      echo "$f not there wget address is $wget_address"
      if wget -r $wget_address -O $f ; then
        good=$(($good+1))
        echo "Got $f hooray! num Good=$good"
      else
        bad=$(($bad+1))
        echo "Failed getting $f :-( num Bad=$bad"
      fi
    fi
  done
  echo "Good=$good Bad=$bad Ugly=$ugly  for $dstr"
done

