Loop through data\mail directory only

I require to loop through the data\mail directory only and retrieve first dB,get all the documents from that dB and copy across to a new directory

(data\mail\archive). Then loop through remaining Db’s and do the same…

Can someone help with the code, please. Cut down version…

Set directory = session.GetDbDirectory(“App01”)

Set db = directory.GetFirstDatabase(DATABASE)

’ Want oto identfy the mail directory here and loop

While Instr(db.filepath,“mail”) <> 1

Set archiveDb = db.CreateCopy(archiveServer, archiveFile)

Set collection = Source.AllDocuments

Set doc = collection.GetFirstDocument()

     ' Okay we need to Archive docs prior to a specified a date

While Not(doc Is Nothing)

	If ( doc.Created < Datenumber( 2003, 01, 01 ) ) Then

		'Copy all Documents to TARGET

		Call doc.CopyToDatabase( archiveDb )

	End If	

	Set doc = collection.GetNextDocument(doc)

Wend

set db = directory.GetNextDatabase

Wend

Subject: loop through data\mail directory only

Look at the Dir function. This allows you to specify a folder & then loop through the files in it.

Subject: loop through data\mail directory only

… your while-loop checks for instr(filePath, "mail"). In the look do your action only with no archive in filepath, i.e.If Not (instr(filepath, "\archive") > 0) then

end if