%REM Agent Fix Folders Created Feb 24, 2012 by Declan Lynch Description: Fixup Folders with spaces in the name %END REM Option Public Option Declare Sub Initialize Dim s As New NotesSession Dim db As NotesDatabase Set db = s.Currentdatabase Dim docDesignNote As NotesDocument Dim strID As String Dim origTitle As String Dim newTitle As String Dim nnc As NotesNoteCollection Set nnc = db.CreateNoteCollection(False) nnc.SelectFolders = True nnc.SelectionFormula = { !@Begins($TITLE; "(") } ' skip Inbox and other system folders. nnc.BuildCollection strID = nnc.GetFirstNoteId Do While strID <> "" Set docDesignNote = db.GetDocumentByID(strID) origTitle = StrLeft(docDesignNote.GetItemValue("$TITLE")(0) & "|", "|") newTitle = Trim(origTitle) newTitle = Replace(newTitle," \","\") If origTitle <> newTitle Then Print "Fixing : " + origTitle + " : " + newTitle Call docDesignNote.Replaceitemvalue("$TITLE",newTitle) Call docDesignNote.Save(true,false,false) End If strID = nnc.GetNextNoteId(strID) Loop End Sub