Commit c88ec74a authored by Robert Ricci's avatar Robert Ricci

Simple script to collect all files for the class in one place

Intended to be called from the Makefile; make is annoyingly bad at
this.
parent 41e88bb6
#!/usr/bin/perl -w
#
# Unfortunately, make is poorly suited to doing this
#
use strict;
sub transmogrify($);
sub cleanup(@);
my $CLASSDIR = "class";
my @handouts = `ls assignments/*/handout.pdf`;
my @lecturenotes = `ls lectures/*/lecturenotes.pdf`;
my @others = ("syllabus", "schedule");
@handouts = cleanup(@handouts);
@lecturenotes = cleanup(@lecturenotes);
foreach my $file (@handouts, @lecturenotes) {
my $command = "cp $file $CLASSDIR/" . transmogrify($file);
print "$command\n";
system "$command";
}
foreach my $file (@others) {
my $command = "cp $file/$file.pdf $CLASSDIR/$file.pdf";
print "$command\n";
system "$command";
}
sub transmogrify($) {
my ($path) = @_;
if (!($path =~ /^(\w+)\/(\w+)\/([\w.]+)$/)) {
die "String $path is not in the right form\n";
}
my ($type,$which,$file) = ($1, $2, $3);
# Make these filenames a bit prettier
$file =~ s/lecturenotes/notes/;
return "$which-$file";
}
sub cleanup(@) {
my @list = @_;
chomp @list;
@list = grep(!/template/,@list);
return @list;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment