Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[d6f438]: split.pl Maximize Restore History

Download this file

split.pl    40 lines (37 with data), 1.0 kB

 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
#!/usr/bin/perl -w
use strict;
use diagnostics;
# requires pdftk to be installed, and something UNIX-like in
# general.
#
# LGPL license, 2005 Copyright Egon Willighagen
my @articles = `find . -name "split.config"`;
foreach my $article (@articles) {
$article =~ s/\n//g;
print "Reading file $article...\n";
open (CONFIG, "<$article");
my $issue = "";
my $pages = "";
while (<CONFIG>) {
my $line = $_;
if ($line =~ m/issue=(.*)/) {
$issue = $1;
} elsif ($line =~ m/pages=(.*)/) {
$pages = $1;
}
}
if (length($pages) > 0 && length($issue) > 0) {
print " ... config OK\n";
$article =~ m#$issue/(.*)/split.config#;
my $artID = $1;
if (length($artID)) {
print " .. article ID: $artID\n";
if (-e "cdknews$issue.$artID.pdf") {
print " ... already extracted\n";
} else {
`pdftk A=archive/cdknews$issue.pdf cat A$pages output cdknews$issue.$artID.pdf`;
print " ... extracted PDF\n";
}
}
}
}