#!/usr/bin/perl
#
###################

foreach $script (glob("*update.sh")) {
    $script =~ /(.*)update.sh/;
    $model = $1;
    print " Found model $model\n";
    if ( ! -d $model ) {
	warn " Directory not found for $model\n";
	system("mkdir -p $model");
    }
# Open script to find files to copy
    open(IN,"<$script") or die "Unable to open $script: $!\n";
    while(<IN>) {
	if (/\$SRCDIR\/(\S+)/) {
	    $bfile=$1;
	    print "Found file $bfile in $script; copying to $model/...\n";
	    system("cp -av $bfile $model/");
	}
    }
    close(IN) or die "Unable to close $script: $!\n";
}
exit;
