I am not sure if best approach would be a plugin. Maybe an WP-CLI tool launched on demand will get better results with no overhead.