Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*
- script by Phil Stokes
- www.applehelpwriter.com
- 2014
- Purpose:
- Mail.app: Delete empty sub-mailboxes of a local ('On my mac') mailbox
- The script below will delete the empty sub-mailboxes of the parent box whose name you supply in the dialog. i.e., if you supply the name 'Parent' then this
- Parent
- Child A (0)
- Child B (0)
- Child C (1)
- will end up with
- Parent
- Child C (1)
- However, tread lightly. It only goes one-level deep. It will ignore any subboxes of subboxes. Thus if you have
- Parent
- Child A (0)
- SubChild (1)
- Child B (0)
- and you supply the 'Parent' to the script, you'll end up with
- Parent
- Note there are no confirmation 'warnings' boxes. It's pretty ruthless. You use this at your own risk.
- *)
- --
- display dialog "Name of the parent mailbox:" default answer ""
- set mbx to text returned of the result
- tell application "Mail"
- tell mailbox mbx
- set i to 1
- repeat while (count of its mailboxes) is not 0
- try
- if (number of messages of its mailbox i) is 0 then
- set aName to name of its mailbox i
- tell application "Mail" to delete mailbox aName
- else
- set i to i + 1
- end if
- on error
- exit repeat
- end try
- end repeat
- end tell
- end tell
- --EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement