What I posted was not designed to retroactively update all of the posts. It is designed up return the correct values when using get_field() or to load the values as a default when editing a post. This won’t do anything to the existing posts
Most people are looking for something they can just run by loading a web page. It could be batch processed with a cron or if you created way to run it that will not time out where you can set the max execution time. Other than telling you that you could do this and you would use update_field to update the values of every post, I don’t have code that will do this. Since the update_field() function will require the field key of the field you want to update it’s not something that is generic.
1) Run a query to get every post
2) Loop through the posts
3) Get all attachments for each post
4) Call update field using the field key, the value will be an array of post IDs.
With 160 posts it is very likely that this will time out if you try to run in through a browser.
You might be able to speed up the process using $wpdb and do the db queries yourself, that would be beyond what I can help you with.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!