How can I automate this process?