Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find all Notes databases on my computer

Status
Not open for further replies.

renniw1

Technical User
Jan 21, 2003
7
0
0
US
Hi,
Is there a way to list all the database titles on my computer using LotusScript in NotesDesigner? Thanks.

Ren
 
Use the NotesDbDirectory class and write yourself an agent that checks out you data directory.
If you want to check all folders, you need to write a recursive function.
If you need help, I have some code lying around that could help.

Pascal.
 
Sure, if you have some code that might help can you post it. Thanks.
 
Here you go :

Code:
Function explore_dirtree(prevdir As Variant,inidir As Variant,db As notesdatabase,recurse As Integer)
	Dim paramdoc As notesdocument
	Dim filelist As notesitem
	Dim dirlist As notesitem
	Dim dirvalue As String
	Dim filefound As Integer
	
	Set paramdoc=db.createdocument
	Set filelist = New notesitem(paramdoc,"filelist","")
	filefound = False
	'build list of files
	dirvalue = Dir$("*.*",ATTR_NORMAL)
	Do While dirvalue <> &quot;&quot;
		If Not(dirvalue = &quot;.&quot; Or dirvalue = &quot;..&quot;) Then
			Call filelist.appendtotextlist(dirvalue)
			filefound = True
		End If
		dirvalue = Dir$()
	Loop
	Delete catdoc
	Set dirlist = New notesitem(paramdoc,&quot;DirList&quot;,&quot;&quot;)
	'build list of directories
	dirvalue = Dir$(&quot;*.*&quot;,ATTR_DIRECTORY)
	Do While dirvalue <> &quot;&quot;
		If Not(dirvalue = &quot;.&quot; Or dirvalue = &quot;..&quot;) Then
			If filefound Then
				If Not(filelist.contains(dirvalue)) Then
					Call dirlist.appendtotextlist(dirvalue)
				End If
			Else
				Call dirlist.appendtotextlist(dirvalue)
			End If
		End If
		dirvalue = Dir$()
	Loop
	If recurse Then
		Forall x In dirlist.values
			If x <> &quot;&quot; Then
				dirvalue = inidir & &quot;\&quot; & x
				Chdir dirvalue
				Call explore_dirtree(prevdir,dirvalue,db,recurse)
			End If
		End Forall
	End If
	Chdir prevdir
End Function

Explanations :
This is an extract of the code I used to make a document history of a directory.
This function needs to be called with target directory as prevdir and inidir, db as current notesdatabase and True if you want all subdirectories, or False if not.
What you must understand is that Notes cannot work simultaneously on files and subdirectories in a directory. You can study the files in a directory, then the subdirectory entries in a second pass. Actually, that is a good thing, since you do not need to worry about an entry being a subdirectoy with a file-like name ;-).
What this code does is, for every directory, it makes a doc that enables a list of files and a list of directories.
Then it studies the directory entries and lists all files.
It does the same with all subdirectories.
Then, if you have specified True for Recurse, for every subdirectory entry, it calls itself recursively. At the end, it goes back up to prevdir. Given that none of the list docs are saved, they all disappear at end of execution.
And that's all there is too it.
Of course, you will probably want to do a bit more, like list only Notes files and not any file, then record where you found it.
You can do so in the file section. I'm sure you'll be able to pick it up from here, but if you get stuck let me know.
Good luck !
 
Wow Pascal, I'm amazed! You make LotusScript look like a REAL programming language!!!

me Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top