calibredb add_format book_id /path/to/format/file
https://manual.calibre-ebook.com/gen...calibredb.html
But you will have to write a script that traverses the calibre library folder gets the path to the kepub file, extracts the book_id fromthe foldername and then moves the kepub file to /tmp and calls calibredb add_format to add it properly.