#!/bin/bash
mkdir /tmp/tampon
ls -l > /tmp/tmpls
while read line
do
  unset fileto
  filefrom=`echo $line | awk  '/->/ {print $9}'`
  fileto=`echo $line | awk  '/->/ {print $11}'`
  rep=`pwd`
  if [ ! -v $fileto ] ; then
    mv $fileto /tmp/tampon
    rm $filefrom
    mv /tmp/tampon/$filefrom .
    ln -s $rep/$filefrom $fileto
  fi
done < /tmp/tmpls