Very new to Script Editor and AppleScript, but have a short (successful) script to empty “Trash” in all Apple Mail accounts. Trash is properly emptied, however, prompt to Cancel/Erase continues to appear, requiring manual response, which I would like to eliminate, but seem (so far) unable to resolve. Any help greatly appreciated! (Hope this is properly posted!)
Jeff Anderson
Script is here (to be executed via bash):
#!/bin/bash
osascript <<EOF
tell application “Mail” to activate
tell application “System Events”
tell process “Mail”
click menu item “In All Accounts…” of menu “Erase Deleted Items” of menu item “Erase Deleted Items” of menu “Mailbox” of menu bar 1
delay 0.5 – brief wait for the confirmation sheet
if exists sheet 1 of window 1 then
click button “Erase” of sheet 1 of window 1
end if
end tell
end tell
EOF