Skip to main content
    Country/region select      Terms of use
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

Occasionally one comes across a mail file containing hundreds of folders -- and in such cases, often many of them are empty.  The contents have been archived out, but there's no mechanism for finding unsued folders. Doing so manually is laborious -- so much so that most users don't bother to start. But if you're running up against some limit -- on the size of an outline, for instance -- it may be really necessary to locate and delete the empties.

Attached is an agent script to locate every empty folder in a mail file, and prompt the user which they would like to delete.

The key for finding folders efficiently, is the NotesNoteCollection.

Dim nnc As NotesNoteCollection
Set nnc = db.CreateNoteCollection(False)
nnc.SelectFolders = True
nnc.SelectionFormula = { !@Begins($TITLE; "(")  } ' skip Inbox and other system folders.
strID = nnc.GetFirstNoteId
' build a list of folders that are candidates for deletion. We use a Note Collection to get the folders because it's
' a lot faster than iterating thru the db.views array.
Do While strID <> ""
       Set docDesignNote = db.GetDocumentByID(strID)
       strTitle = Strleft(docDesignNote.GetItemValue("$TITLE")(0) & "|", "|")

        Set view = db.GetView(strTitle)

if view.EntryCount = 0 Then
' record this folder as a deletion candidate.

       End If
       strID = nnc.GetNextNoteId(strID)

Why not just iterate through the db.Views array? Because (last I checked) when you get a Notes view object, the view index is updated. If you have less-used views in an application, it may take some time to do for all views when all you wanted was to check whether they were folders -- it also makes the views look like they are used when perhaps they aren't, frustrating efforts to identify unused views by flagging those whose indexes haven't been updated recently, as I've discussed in this blog. Unfortunately, there's no simple search for locating empty folders, so peeking into each folder is the only way to tell -- but that's still some bit faster.

Here's the full code: killEmpties.lss

Andre Guirard | 26 February 2008 03:17:00 AM ET | Caribou Coffee, Plymouth, MN, USA | Comments (1)

Search this blog 


    About IBM Privacy Contact