I am creating a script that will incorporate multiple variables organized in a spreadsheet for pdftk. I have a 1000 page pdf that I have to split into about 300 individual pdfs. The basic command line to extract pages is as follows:
$ pdftk file.pdf cat 1-7 output newfile.pdf
file.pdf = 1000 page original file.
1-7 = pages to be extracted
newfile.pdf = new output file (pages 1-7 of 1000)
If I have a spreadsheet with all the sequential page numbers to be extracted in one column and the corresponding filename in another column, how do I insert those into the command line and have the script work through the entire list? I would appreciate any suggestions on how this could be done easier.
Thanks, for all the suggestions. One more question. If I want to insert two variables to create a more complex output filename, what would be the easiest way?
For example, if my flat file/spreadsheet included a third variable, a year, it would look like this:
I wanted to combine the second and third variables ("newfile1" and "1993") together, separated by a dash/hyphen as part of the output filename, the actual commands would look like this:
Simply add another variable (say s3) in the loop, and join them together later, ( ... output "$s2"-"$s3".pdf ... ).
Equally simple is modifying the posted perl code.