PDF Chunking Loop Design Question

As mentioned (briefly) before -- work backwards.

You know your last page.
You know each of your chapters' start pages.
The previous chapter's end page will be the current chapter's start page - 1.

Add End Pages.kmmacros (6.1 KB)

Image

You can, obviously, format the output however you want -- I've put the end pages inside their own (( )).

It's much easier, and much more obvious what's happening, if you use the ranges as numbered in your TOC and apply your offset later. You can do that one at a time if you are feeding each chapter to a script -- if you want to pass the whole TOC to your script there's a neat way of applying the offset first using a calculated "Search and Replace":

That looks more complicated than it is because you've used (( and )) to delimit your numbers -- they're special characters in a regex so need to be escaped.