Indeed there is no way to specify a reference to the last page, without explicitly specify its value for each PDF. I've now fixed this by adding a "last" named keyword to the page specifications rules, so in the next release it will be possible to write e.g.
3,5-7,last, or just
last in your case, to refer the last page.
Meanwhile your solution is perfectly viable. Or you can use the new
dynamic text script functionality to stamp only the last page. You just need to add a text stamp object to the stamp template, set it to dynamic and its text to refer the script name to call using the
[<ScriptName>](params) format. The script can be something like this:
function StampLastPage(text) {
return CurrentTask.PageNumber == BatchFile.NumPages ? text : '';
}
The script is created from the dynamic object settings configure dialog.
For a script named "StampLastPage", and having the "section" and "next_volume" values passed from the command line in the "DynCustomText" parameter, as in your example, the dynamic text object text would be:
[<StampLastPage>](Section [C1] continued in Volume [C2]).
And the command line simplified to:
PDFShellTools stamp -s "DynCustomText='%section%','%next_volume%'" Template=SectionContinued.stp "%output%"
Obviously the dynamic text script can be much more complex, and probably even integrate all the logic of your external script and calculate by itself these "section" and "next_volume" values.