Establish the folder size

Is there any possibility to find out how big each several folder is?

e.g. Inbox, Sent Items or other user created folder
verto33Asked:
Who is Participating?
 
mbonaciCommented:
verto33,
here you are:

Function getDbFolderSize( db As NotesDatabase, folderName As String ) As Double
%REM Mb¤, 07.06.2006.    
    'The function returns the sum of all doc sizes in the "folderName" folder (or view)
    'To get the sum of all doc's sizes of all db's folders pass empty string as the folderName

    'Requirements:
        'all folders have to have the column that lists the doc's size
        'that column:
            'has to have name (title) - "Size" (not case sesitive)
            'has to be totaled

    'recommended @Formula for the Size column:
    @If( @IsDocTruncated;
        @If( @TextToNumber( @Version ) < 172;
            @DocLength;
            @DocOmittedLength + @DocLength );
        @DocLength )
%END REM
    On Error Goto Errhandler
    Dim nav As NotesViewNavigator
    Dim row As NotesViewEntry
    Dim pos As Integer
   
    If folderName = "" Then    'Get all folder's size
        Forall folder In db.Views
            If folder.IsFolder Then
               
                'To get the index of Size column
                pos = -1
                Forall col In folder.Columns                    
                    If Lcase( col.Title ) = "size" Then
                        pos = col.Position - 1
                        Exit Forall
                    End If
                End Forall
               
                Set nav = folder.CreateViewNav
                Set row = nav.GetLast
               
                'Check if there are docs in the folder and that has the column named "Size"
                If Not row Is Nothing And pos <> -1 Then
                    getDbFolderSize = getDbFolderSize + row.ColumnValues( pos )
                End If
               
            End If
        End Forall
    Else
        Dim fldr As NotesView
        Set fldr = db.GetView( folderName )
        pos = -1
       
        'To get the index of Size column
        Forall column In fldr.Columns
            If Lcase( column.Title ) = "size" Then
                pos = column.Position - 1
                Exit Forall
            End If
        End Forall
       
        Set nav = fldr.CreateViewNav
        Set row = nav.GetLast                    
       
        If Not row Is Nothing And pos <> -1 Then
            getDbFolderSize = row.ColumnValues( pos )
        End If
       
    End If
   
leave:
    Exit Function    
Errhandler:
    Dim errMsg As String    
    errMsg = "Error in function - getDbFolderSize" & Chr$(10) & "Line: " & Cstr( Erl ) & Chr$(10) & "Err No: " & Err & ": " & Error$
    'Msgbox errMsg
    Print errMsg
    Resume leave
End Function


You call it like this (for Inbox folder), let's say from an action button:

Sub Click(Source As Button)
    Dim s As New NotesSession
   
    Msgbox |Inbox folder's size:

| & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "($Inbox)" ) / 1024, 2 ) ) & " Kb"
   
End Sub

Keep in mind that the function @DocLength returns the approximate size of a document.

Marko
0
 
mbonaciCommented:
Hi verto33,
the first that comes to mind is to go through the view/folder doc by doc and summarize the sizes:

The size of a document in bytes:
    size = notesDocument.Size

Hope this helps,
Marko
0
 
mbonaciCommented:
verto33,
this is quicker solution from Qualitee:

http://www.experts-exchange.com/Applications/Email/Lotus_Notes_Domino/Q_21269312.html

Hope this helps,
Marko
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Sjef BosmanGroupware ConsultantCommented:
A folder has no size...
0
 
verto33Author Commented:
All folders have the doc size column present, and that it is totaled.
I changed the Inbox and then selected "Action Upgrade Folder design"
I created an Agent and pasted the Script.

Error message: Variant doesn't contain an object.

Agent Trigger = on event, Action menu selection
Target = All document in the database

The code is under Initialize in the Agent.

0
 
mbonaciCommented:
verto33,
I'm just finishing the code for you, wait a few minutes.

Marko
0
 
Sjef BosmanGroupware ConsultantCommented:
Could you tell me why you need to know the "size" of a folder? Removing documents from a folder won't reduce the size of a database, since a folder doesn't "contain" documents: it contains references to documents.
0
 
marilyngCommented:
Another thought -- not sure if this is what you were looking for..

Open Administrator
Select the Server
Click on the Files tab
Select the Database
On the Tools Bar (right) expand Database
Select Manage Views

List of all views and their sizes appears for selected database.

You can purge the view index.
0
 
mbonaciCommented:
Just to be clear, this tool marilyng is talking about lists the size of view's index, not size of it's documents.

Marko
0
 
verto33Author Commented:
I pasted the above code. (Created an agent)

I created a button and pasted the code for it,too. I get an error message in the line:

| & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "($Inbox)" ) / 1024, 2 ) ) & " Kb"

The error message is following:

Illegal parenthesized reference: GETDBFOLDERSIZE
0
 
mbonaciCommented:
verto33,
on the form where the button is:
go to Globals - Declarations and paste the function getDbSize there.

The function will be placed after Terminate form event.

Then preview the form and click on the button.

Hope this helps,
Marko
0
 
verto33Author Commented:
I know the messagebox expression this way:  e.g.

Messagebox "Here my text.", 64, "Warning!"

What does the pipe mean in your line?
0
 
mbonaciCommented:
verto33,
forget that, that's ok - the pipe is same as quotation mark but you can go to new line (use enter) when using pipe and then you'll get multiline messagebox.


Marko
0
 
mbonaciCommented:
verto33,
the error message says that it can't find your function (that's because you put it in an agent).
Functions are placed at Global if you want to call them from any form design element's code (like your button).


Hope this helps,
Marko
0
 
verto33Author Commented:
I pasted the code at Global (on the Memo form) no error

Created the button on the Memo form and called it from there. I got the same error in the same line.
Illegal parenthesized reference: GETDBFOLDERSIZE

I know that isn't nice to place it on the Memo form but I don't know where I could place it.
0
 
verto33Author Commented:
I found below solution but when I paste "Option Public" I get the error message:

"Public is not allowed in this modul"

This is what I found:

"Illegal parenthesized reference with the name of the script library is displayed."  
 
Solution
In at least one case, this issue occurred when the "Option Public" line was inadvertently deleted from the Script library options section. Without that line, the script library could not be read by another LotusScript element.
To correct the issue, add Option Public back into the LotusScript Script Library options
 
0
 
verto33Author Commented:
I did following:

im Designer-Client: Tools -> Recompile All LotusScript

but the error is still  there.
0
 
verto33Author Commented:
I found this as well, but didn't help

The function that you are calling is not within the scope of the calling
function or event. If the user defined function is part of a script library
(ex: script library1), then in the form globals, "options", write the statement:
use "script library1".
0
 
Sjef BosmanGroupware ConsultantCommented:
> I found below solution...
What solution?

When compiling, it also gave you the module or element with the error. It is either in that element, or in the libraries the element uses.

Did you place the code in the (Global) section or in the Form section?

I think you can better place the function in a separate script library, then "Use scriptlibraryname" in the code.
0
 
verto33Author Commented:
Sorry, I didn't paste it in the Global. It's my fault.

Now it works.

I will list all the folder size in one message box. I get a two lines message box when I paste the code from mbonaci.
But if I paste 2 or 3 lines additionally I get an error. "Unexpected: String Constant; Expected Statement"
I want to learn how to create a multiline message box.
Please have a look at the code below, are the pipes in the wrong places?

Msgbox |Inbox folder's size:

| & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "($Inbox)" ) / 1024, 2 ) ) & " Kb"
      | & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "Finance" ) / 1024, 2 ) ) & " Kb"      
      | & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "SLeaders" ) / 1024, 2 ) ) & " Kb"

0
 
Sjef BosmanGroupware ConsultantCommented:
There's a begin-pipe and an end-pipe, but the pipes can be replaced by { and } ; these characters are easier to be recognised as string delimiters.
0
 
verto33Author Commented:
When I use a start and an end pipe then the code itself between the pipes will be displayed and not the executed code.
When I put the end pipe at the beginning of the last line then the last line's code is executed but the 2 lines above it is displayed as normal text and code isn't executed.

I can have the program to execute the code and display it in two lines but the moment I make three lines I always get an error message.

The messagebox can display normal text in several lines but not execute codes in several lines.

How many pipes should I write and where should I place them if I want a messagebox with three lines?

I don't understand with the  { and } ;
 Should I put { and } ; at the end of all lines?
0
 
Sjef BosmanGroupware ConsultantCommented:
The following are equivalent:
    "this is a string"
    |this is a string|
    {this is a string}

The same goes for the following equivalent strings spanning more than one line:
    "this is a very" & _
    " long string"
    |this is a very
 long string|
    {this is a very
 long string}

I could be mistaken about the newline inside the string, but that can easily be solved.  
0
 
verto33Author Commented:
Yes, I can display text in multiple lines within a message box with your examples above.
That's all right.

The problem is that if I place not text but codes inside the pipe or brackets, the code will be displayed as normal text.

This is a two liner and works OK. (displays the code's result and not normal text)

Msgbox |Inbox folder's size:

| & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "($Inbox)" ) / 1024, 2 ) ) & " Kb"

How to make a three liner of it? Displaying the e.g. Inbox's size two times in different lines?
0
 
Sjef BosmanGroupware ConsultantCommented:
Each string should be enclosed in a pair of "" or || or {}

Msgbox |Inbox folder's size:

| & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "($Inbox)" ) / 1024, 2 ) ) & " Kb" _
     & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "Finance" ) / 1024, 2 ) ) & " Kb" _
     & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "SLeaders" ) / 1024, 2 ) ) & " Kb"

or

Msgbox |Inbox folder's size:

| & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "($Inbox)" ) / 1024, 2 ) ) & " Kb" & |
     | & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "Finance" ) / 1024, 2 ) ) & " Kb" & |    
     | & Cstr( Round( getDbFolderSize( s.CurrentDatabase, "SLeaders" ) / 1024, 2 ) ) & " Kb"

0
 
verto33Author Commented:
Thanks,

I'm using the second variation now. It executes the code and displays in different lines.
I didn't succeed before because I didn't put the ampersand sign at the end before the pipe.

The first variation executes and displays the code in a right way but in 1 line. The three sizes are in 1 line.

But I'm glad to have a messagebox with multilines. I wouldn't have imagined that it takes so long to create a multiline box.
0
 
Sjef BosmanGroupware ConsultantCommented:
Dim CR As String

CR= Chr$(13)
Msgbox "Inbox folder's size:" & CR & _
    Cstr( Round( getDbFolderSize( s.CurrentDatabase, "($Inbox)" ) / 1024, 2 ) ) & " Kb" & CR & _
    Cstr( Round( getDbFolderSize( s.CurrentDatabase, "Finance" ) / 1024, 2 ) ) & " Kb" & CR & _
    Cstr( Round( getDbFolderSize( s.CurrentDatabase, "SLeaders" ) / 1024, 2 ) ) & " Kb"
0
 
verto33Author Commented:
Perfect
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.