Sounds like a job for ScanTailor. I'm not aware of an actively developed alternative. The version on my system comes from ScanTailor Advanced [3].
[1]: https://scantailor.org/
[2]: https://github.com/scantailor/scantailor
[3]: https://github.com/4lex4/scantailor-advanced