Take a look at https://lists.gnu.org/archive/html/lilypond-user/2023-09/msg00136.html
which I posted just a few days ago in reply to another question. It's a piece of Scheme code that auto-adds a blank page when needed.
signature.asc
Description: This is a digitally signed message part