Automatically deleting old emails in Gmail

As a follow up to my post Deleting old emails in Gmail 3 years ago, I’ve now found a way to automatically delete old emails from Gmail.
This trick uses the rather unknown Google Scripts, a Javascript engine which runs on Googles servers.

Pop to Gmail and test some searches, eg label:webserver older_than:1m this will find all emails labelled webserver and are older than 1 month (full list of search options here.

Once you are happy that your search result has found the emails you don’t want, go to script.google.com.