[EMAIL PROTECTED] wrote:
> hi, I'm using wget with this url:
> 
> http://www.twis.org/audio/podpress_trac/web/147/0/TWIS_2007_09_11.mp3
> 
> the directory named 147 increases by 1 each week, corresponding to an mp3
> with a new date. I can use macros to automatically deal with a changing
> date, but haven't been able to find out how to make wget go to directory
> 148 the following week,

IIUC, the problem is just slightly above simple, involving
calendar calculations. :-) GNU date might help you. It isn't
perfect, though.

#! /bin/sh

# If you know the rule of publication dates, pick one as a reference
# date and add weeks adjusted for directory numbers.
# This should work for the current year.

reference_day="2007-09-04"
week_of_refday=$(date --date="${reference_day}" +%W)
weeks_since=$(($(date +%W) - ${week_of_refday}))
the_dir=$(date --date="${reference_day} ${weeks_since} weeks" +%W)
the_day=$(date --date="${reference_day} ${weeks_since} weeks" +%Y-%m-%d)

# adjust $the_dir by an amount reflecting the initial count

the_dir=$((${the_dir} + 110))

prefix="http://www.twis.org/audio/podpress_trac/web";

# replace echo with wget if this suits your needs
echo ${prefix}/${the_dir}/0/TWIS_${the_day}.mp3

Reply via email to