Größe der Mailbox berechnen

AppleScript Mailbox Size

Hm, wenn ich das richtig sehe, bekommt man in Apple Mail nicht wirklich die Größe einer einzelnen Mailbox heraus. Schon die Größe der Postfächer auf dem IMAP Server, aber bei POP3 wohl nur die der auf dem Server gespeicherten Emails. Jetzt könnte man natürlich in ~/Library/Mail einfach nachsehen oder sich die schlaflose Nacht mit einem AppleScript vertreiben:

Code zum markieren einmal anklicken

Mailbox Size Script

  Created by Hubi on 08.05.2009

  Copyright 2009 hubionmac.com. All rights reserved.

set c_date to do shell script “date ‘+%d.%m.%Y'”

set myoutput to “Mailstats vom “ & c_date & return

do shell script “echo “ & quoted form of myoutput & “| cat>/tmp/mailboxsize_” & c_date & “.txt”

tell application “Mail”

set accountlist to name of every account

set accountlist to (choose from list accountlist with multiple selections allowed)

if (count of accountlist) > 0 then

repeat with c_account in accountlist

set myoutput to “Account-Name: “ & c_account

do shell script “echo “ & quoted form of myoutput & “| cat>>/tmp/mailboxsize_” & c_date & “.txt”

set account_sum to 0

repeat with mb_i from 1 to count of every mailbox of account c_account

set c_mailbox_name to (name of mailbox mb_i of account c_account) as text

set mailbox_size_t to message size of every message of mailbox mb_i of account c_account

set mailbox_size to 0

repeat with s in mailbox_size_t

set mailbox_size to mailbox_size + s

end repeat

set account_sum to account_sum + mailbox_size

set mailbox_size to do shell script “echo ‘scale=2; “ & mailbox_size & “/1024/1024’|bc”

set myoutput to tab & c_mailbox_name & “: “ & mailbox_size & ” MB”

do shell script “echo “ & quoted form of myoutput & “| cat>>/tmp/mailboxsize_” & c_date & “.txt”

end repeat

set account_sum to do shell script “echo ‘scale=2; “ & account_sum & “/1024/1024’|bc”

set myoutput to tab & “==================================”

do shell script “echo “ & quoted form of myoutput & “| cat>>/tmp/mailboxsize_” & c_date & “.txt”

set myoutput to tab & “SUMME: “ & account_sum & ” MB”

do shell script “echo “ & quoted form of myoutput & “| cat>>/tmp/mailboxsize_” & c_date & “.txt”

end repeat

end if

end tell

do shell script “open /tmp/mailboxsize_” & c_date & “.txt”