I wrote some python code some while back, exthupdt.py - see
https://www.mobileread.com/forums/sho...d.php?t=144056 - I use it to update mobi EXTH data to suit the way I organised my ebooks. You may be able to reuse the code for what you wish to do ...