Mac Automation Scripting Guide: Getting to Know Script Editor https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/GettoKnowScriptEditor.html#//apple_ref/doc/uid/TP40016239-CH5-SW1
Daring Fireball: Simple Inbox Archiving Script for Apple Mail https://daringfireball.net/2007/07/simple_inbox_sweeper