in reply to combining PDFs

I'm using a system command with the pdftk function, but I can't get the output file to have the date stamp in the file name.

Extract the date stamp out of the respective input file name (e.g. using a regex), and put it onto the output file name that you specify in the pdftk command.

What does your system command look like?  And what have you tried so far?

Replies are listed 'Best First'.
Re^2: combining PDFs
by NorthShore44 (Novice) on Jun 30, 2010 at 19:18 UTC
    The system line is

    system "pdftk /home/Memos/exhibit1_29JUN2010.pdf /home/Memos/exhibit2.pdf cat output /home/exhibits_29JUN2010.pdf";

    I've tried using a wildcard (*) to take the place of the datestamp (29JUN2010) in the first file's name, but I'm still having the problem of getting the combined file to have the datestamp in its name.

      Not sure I understand. Have you hardcoded those file names in the system call?  I would guess that you get the input file names from somewhere (listing directory contents, some config file, user input...).  Otherwise, how would the program work if there's a new date stamp...

      So why not simply dynamically create the output file name according to the date stamp found in the input file?  For example:

      my $in1 = "exhibit1_29JUN2010.pdf"; my $in2 = "exhibit2.pdf"; my ($date) = $in1 =~ /_([^_]+)\.pdf$/; # extract date my $out = "exhibits_$date.pdf"; # create output file name system "pdftk /home/Memos/$in1 /home/Memos/$in2 cat output /home/Memos +/$out";

      Or maybe

      my $dir = "/home/Memos"; my $in1 = <$dir/exhibit1_*.pdf>; my $in2 = "$dir/exhibit2.pdf"; my ($date) = $in1 =~ /_([^_]+)\.pdf$/; my $out = "$dir/exhibits_$date.pdf"; system "pdftk", $in1, $in2, "cat", "output", $out;