-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcopy_talks.pl
More file actions
48 lines (34 loc) · 915 Bytes
/
copy_talks.pl
File metadata and controls
48 lines (34 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env perl
use 5.016;
use strict;
use warnings;
use Text::CSV_XS;
use File::Copy;
use File::Spec;
#my $csv = Text::CSV_XS->new({sep_char => "\t"});
my $file = shift;
open(my $fh, '<', $file) or die "Couldn't open file: $!";
my $talkdir = 'Talks';
if (! -e $talkdir) {
mkdir $talkdir;
}
while (my $line = <$fh>) {
next if $line =~ /^#/;
chomp $line;
#say $line;
my ($abstract, $day, $talk, $poster, @rest) = split("\t", $line);
next unless $talk;
my $from = "BOSC_2017_paper_${abstract}.pdf";
if (! -e $from) {
die "Can't find PDF $from";
}
my $to = "$talk.pdf";
my $daydir = "Day_$day";
my $path = File::Spec->catdir($talkdir, $daydir);
if ( ! -e $path ) {
mkdir $path;
}
my $filepath = File::Spec->catfile($talkdir, $daydir, $to);
say "Copying from $from to $filepath";
File::Copy::cp($from, $filepath);
}