Nested Symlinks?

Please don't laugh or call me a fool...

I'm trying to set up a script that will go through my Music File directory and generate a set of symbolic links in a directory called "What's New". Within that directory there will be a "30 Days", "3 Months", "6 Months" and "A Year" directories. Within each of those my script should create symlinks based on the mtime of the directories that the 'find' command returns. The general reason for me doing this is that I've been downloading stuff from emusic.com and sometimes I find myself forgetting what I downloaded. Having a directory with "fuzzy" time references would go a long way to helping me remember. So I wrote the script below which almost does what I need. But it has one HUGE glaring error. For some reason, the 'ln' command creates a self referencing symlink within the trailing directory for each directory that matches my mtime arg. So once it's done, I have what I want in the "What's New" directory. But for every directory that 'find' returns I have a symlink in the last directory in the path that points to itself. I'm sure there's something stupid I'm missing in my logic with the 'ln' command. Just to make sure I'm clear, let's say my script finds a directory less than 31 days old:

/mnt/data/mp3/The Rolling Stones/Sticky Fingers

I get the symlink I want in:

/mnt/data/mp3/What's New/30 Days/The Rolling Stones/Sticky Fingers

pointing to:

/mnt/data/mp3/The Rolling Stones/Sticky Fingers

And I also get a new, unwanted symlink in:

/mnt/data/mp3/The Rolling Stones/Sticky Fingers/Sticky Fingers

pointing to:

/mnt/data/mp3/The Rolling Stones/Sticky Fingers

Obviously this is not what I want. So either I'm looping in the wrong way, or I'm making an incorrect assumption about the 'ln' command. I have to admit this is a pretty sloppy script, but I haven't had enough free time to really sit down and really set it up with internal functions. :frowning: Here's my script:

#!/bin/bash

# Define any needed variables first: 'find' variables: 31, 91, 181, 366, search path, "What's New" path

MUSICPATH=/mnt/data/mp3

MONTH[1]=31
QUARTER[1]=91
HALFYEAR[1]=181
YEAR[1]=366

WHATSNEW="$MUSICPATH/What's New"
MONTH[2]="1 Month"
QUARTER[2]="3 Months"
HALFYEAR[2]="6 Months"
YEAR[2]="A Year"
OWNER="root"
GROUP="fileusers"
PERMS="755"

# Create the "What's New" directory if it doesn't exist and set proper owner:group and permissions

if test ! -e "$WHATSNEW"
then
  mkdir "$WHATSNEW"
fi

# First we scan the directory /mnt/data/mp3 for files that are newer than 30 days and dump that to a temp file.  (Maybe do 30, 90, 180, 365 days?)

for a in ${MONTH[1]} ${QUARTER[1]} ${HALFYEAR[1]} ${YEAR[1]}
do
  find $MUSICPATH -type d -mtime -$a > /tmp/$a.out
done

# Next we prep the "What's New" folder in /mnt/data/mp3.  It should be set up to contain "30 Days" "3 Months" "6 Months" "1 Year"

for a in "${MONTH[2]}" "${QUARTER[2]}" "${HALFYEAR[2]}" "${YEAR[2]}"
do
  rm -rf "$WHATSNEW/$a"
  mkdir "$WHATSNEW/$a"
done

# Then we loop through the temp file and create symlinks for the newer folders and files

for a in MONTH QUARTER HALFYEAR YEAR
do

  if test "$a" = "MONTH"
  then
    REPORT="${MONTH[1]}"
    ENDPATH="${MONTH[2]}"
  fi

  if test "$a" = "QUARTER"
  then
    REPORT="${QUARTER[1]}"
    ENDPATH="${QUARTER[2]}"
  fi

  if test "$a" = "HALFYEAR"
  then
    REPORT="${HALFYEAR[1]}"
    ENDPATH="${HALFYEAR[2]}"
  fi

  if test "$a" = "YEAR"
  then
    REPORT="${YEAR[1]}"
    ENDPATH="${YEAR[2]}"
  fi

  while read report
  do
    # The ${report:14} is to strip off the unwanted /mnt/data/mp3/ prefix
    echo ln -s "$report" "$WHATSNEW/$ENDPATH/${report:14}"
  done < /tmp/"$REPORT".out

done

chown -R $OWNER:$GROUP "$WHATSNEW"
chmod -R $PERMS "$WHATSNEW"

# This job is run daily