#!/bin/csh -f

#
# Script to create a new project
#

#
# Variables
#
set projTrackerDataDir = "/usr/local/apache/spnrsupport/htdocs/SPRhome/SPRadmin/PROJ_TRACKER"

################################################################################
# Main
################################################################################

#
# Get today's day of the month
#
set todaysDay = `date | awk '{print $3}'`

echo "Begin to move create files."
foreach createFile (`ls $projTrackerDataDir/*create`) 
#  echo "$createFile"
  set fileDay = `ls -l $createFile | awk '{print $7}'`
  if (($fileDay >= 28) && ($todaysDay > 2)) then
    echo "$createFile is old and needs to be removed."
    mv $createFile $createFile.tmp
    if (-e $createFile) then 
      echo "$createFile still exists"
    endif
  else 
    @ difference = $todaysDay - $fileDay
    if ($difference > 2) then
    echo "$createFile is old and is being removed."
    mv $createFile $createFile.tmp
    if (-e $createFile) then 
      echo "$createFile still exists"
    endif
  endif
end
