Wednesday, December 28, 2011

PDFTK find pdfs and collate them oneliner

Here a oneliner to merge PDF's together that are in a sub-directory structure. (Prerequisite: installed working version of pdftk)
$ find . -type f -name '*.pdf' | 
      perl -ne 'BEGIN {  my @c=() } 
          {     push @c, $_;$_=undef; } 
                END {my $n=65; foreach (@c) 
                { chomp; $x=$x.sprintf " %c=\"%s\"", $n,$_;$y=$y. sprintf " %c", $n; $n++ 
                }; 
                  print "\npdftk $x shuffle $y output collated.pdf;\n" 
          }'

No comments:

Post a Comment