PowerMail Info Script

Ok. I made changes in the AppleScript I posted the other day, so that
folder information is provided for subfolders and sub-subfolders. I'm
probably the only one that hates subfolders in PowerMail, but this script
includes that information for those that use subfolders. The output of
the script looks like this:

Folder count: 72
Subfolder count: 3
Third level folder count: 2
Message Filters: 81
Text Clippings: 24
Signatures: 3

I didn't test for folders nested beyond 3 levels deep (I also didn't test
whether PM is capable of creating folders beyond the third level.) but
this should be sufficient for most people, I think.

<Begin AppleScript>
property FldrCounter : 0
property childrenCount : 0
property grandchildrenCount : 0
property prefC : "Message Filters: "
property preclC : "Text Clippings: "
property presigC : "Signatures: "
property ret : return
property bttnList : {"Thanks", "Put on Clipboard"}
property defBttn : "Put on Clipboard"

to getFldrInfo()
        tell application "PowerMail"
                set the containerList to every message container
                set the FldrCounter to count the containerList
                repeat with x in (the containerList)
                        if exists (message containers of x) then
                                set the childList to every message container of 
x
                                set the childCount to (count the childList)
                                set the childrenCount to (the childrenCount + 
(the childCount))
                                set the FldrCounter to (the FldrCounter + (the 
childCount))
                                repeat with y in (the childList)
                                        if exists (message containers of y) then
                                                set the gchildList to every 
message container of y
                                                set the gchildCount to (count 
the gchildList)
                                                set the grandchildrenCount to 
(the grandchildrenCount + (the
gchildCount))
                                                set the FldrCounter to (the 
FldrCounter + (the gchildCount))
                                        end if
                                end repeat
                        end if
                end repeat
                set the childrenMsg to ("Subfolder count: " & (the 
childrenCount))
                set the gchildrenMsg to ("Third level folder count: " & (the
grandchildrenCount))
                return ("Folder count: " & (the FldrCounter) & return & (the
childrenMsg) & return & (the gchildrenMsg))
        end tell
end getFldrInfo

to concatenateData(fldrInfo, fCnt, clCnt, sigCnt)
        return (fldrInfo & ret & prefC & fCnt & ret & preclC & clCnt & ret &
presigC & sigCnt)
end concatenateData

to displayTotals(statsTxt)
        set the dialogBttn to the button returned of (display dialog statsTxt
buttons bttnList default button 2)
        if the dialogBttn is the defBttn then
                set the clipboard to the statsTxt
                beep
        end if
end displayTotals

tell application "PowerMail"
        set the fldrInfo to my getFldrInfo()
        set the filterCnt to count filters
        set the clipCnt to count text clippings
        set the sigCnt to count text signatures
        set the statsTxt to my concatenateData(fldrInfo, filterCnt, clipCnt, 
sigCnt)
        my displayTotals(the statsTxt)
end tell

<End AppleScript>

-- 
Sometimes even to live is an act of courage.
- Lucius Annaeus Seneca, writer and philosopher

* 867 PowerBook G4 * OS X 10.2.8 * 768 MB Ram *


Reply via email to