Help with resolving page numbers (a regex action perhaps)

I’m wondering if there are any regex experts/scripting experts that could help me out. Here is my problem: I work on PDFs in the Bookends app, then export my annotations (using a shortcut) to Drafts. I end up with a series of highlights with pages numbers, something like this:

Annotation Summary for Smith 2020:
#@2:
Highlight
yada yada yada

#@3
Highlight
yada yada yada

The action for getting highlights from Bookends -→ Drafts works well, and I tend to Find and Replace the “Highlight” to have a cleaner text. But it leaves me with one fussy issue: the page numbers often don’t reflect the page numbers of the publication (which can be a hassle with longer series of annotations). I feel like this is something Regex could solve. I’m wondering if anyone has any suggestions for an action that could “bump” the numbers to the correct pages (I do realize the action would have to be modified each round given each publication would have different page ranges).

How would it be known what page number is correct for each one? Can you describe how to calculate or algorithmically determine the size of a bump for a particular entry?

Hi - to give you an idea, I had a kind soul help me with this years ago with Textsoap (I would paste my annotations into there, then run a custom cleaner). This is the way it’s set up there:


So, each time I would have to click on the automator workflow to change the bump (so, it may be +473, if the page numbers start on page 474 for instance).

But maybe this isn’t possible through Drafts? I have some keyboard maestro macros that make this all run quite seamlessly on the Mac, but I just find myself working with literature annotations extensively on the iPad, so would love to cut out the mac out of the process if I can.

Oops - forgot to respond — see my response below.

My understanding then is that:

  1. On a single pass, each page number is to be incremented by a single value.
  2. The single value should be specified by the user at the start of the process.
  3. All page number lines begin #@, and are immediately followed by one or more digits.
  4. A page number line can end with non-numeric text, e.g. :.

Based on those posts, give this action a try.

It will prompt you to enter a number. That number will then be added to the page numbers.

1 Like

Amazing! Really - super helpful. Where do I send you funds for a coffee or a beer? Thanks.

No problem. There is no obligation at all, but I do have a buy me a coffee page in case people do find my stuff useful and want to fund a coffee shop coding visit :coffee:


I don’t really feel that the forum is the right place to post a direct link to that, but if you follow this Drafts directory search link and select any of the action groups I’ve created, you’ll find that they have a donate a coffee link in them; and you might find the action groups useful too :nerd_face:


1 Like

Cheers! Worth a caffeine “bump” :coffee: for sure!

1 Like