If I had a few hundred posts to update I would more than likely build php cron task that interacted directly with the database.
next best solutions would be to create an acf/load_value filter https://www.advancedcustomfields.com/resources/acfload_value/. If the value === NULL then no value is set, get all of the image IDs uploaded to the post. This second method would mean you don’t need to update anything unless you want to change the gallery.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users