$d = ':'; # delimiter

$todays_date    = "c:\\Test\\Ingest\\date.txt";
$source         = "\\\\phys-cu-10859\\Ingest\\";  # UNC source path, was phys-cu-dungeon
$destination    = "c:\\Test\\Ingest";             # local drive destination
$net_send_pc    = "PHYS-CU39-12130";                # local drive destination



#
# sub get_todays_date
#
# Purpose: gets current date from system
#
# Notes:   returns 2 letter day abbreviation, e.g. Tu for Tuesday
#
# command date /T was output to file and read back in since just running date command
# was not returning date correctly
#
# Used by: main
#
sub get_todays_date {
   #print ("start get_todays_date\n");	# stub

    `date /T > $todays_date`;

    open (IN_TODAY, $todays_date) || die ("error: $todays_date not found");
    $line = <IN_TODAY>;
    close (IN_TODAY);
    chomp ($line);

    ($weekday_month, $day, $year) = split (/\//, $line);  # split date
    ($weekday, $month) = split (/ /, $weekday_month);	  # split weekday and month
    $weekday = substr($weekday,0,2);			  # get first two letters of day
   #$year = substr($year,2,2);				  # get last two digits of year

    print ("date: $weekday\n");	# stub
   #print ("end   get_todays_date\n");	# stub
} # end &get_todays_date



###############################################################################
#
# main
#

&get_todays_date;

if ($weekday =~ /Mo/) {
        $x      = `del $source\\Th*.N* `;
        $x      = `del $destination\\Th*.N* `;
	$result = "Thursday files deleted";
} elsif ($weekday =~ /Tu/) {
        $x      = `del $source\\Fr*.N* `;
        $x      = `del $destination\\Fr*.N* `;
	$result = "Friday files deleted";
} elsif ($weekday =~ /We/) {
        $x      = `del $source\\Sa*.N* `;
        $x      = `del $source\\Su*.N* `;
        $x      = `del $destination\\Sa*.N* `;
        $x      = `del $destination\\Su*.N* `;
	$result = "Saturday, Sunday files deleted";
} elsif ($weekday =~ /Th/) {
        $x      = `del $source\\Mo*.N* `;
        $x      = `del $destination\\Mo*.N* `;
	$result = "Monday files deleted";
} elsif ($weekday =~ /Fr/) {
        $x      = `del $source\\Tu*.N* `;
        $x      = `del $destination\\Tu*.N* `;
	$result = "Tuesday files deleted";
} # end if

`net send $net_send_pc $result`;
