Tip

File/Folder Recursion

In R5 you are able to use OLE in LotusScript. If you have the "Microsoft
Scripting Runtime" refernce on your machine you will be able to use the
following code to recurse through the directory structure on a machine to
identify and/or modify files and folders. I wrote this with the intention of
finding all *.ft folders on a server and logging their size. I was then able
to determine how much space was being utilized by full text indexes in Notes.
Dim FSO As Variant
Dim Files As Variant
Dim SubFolders As Variant
Dim initFolder As Variant
Dim TextFile As Variant

Sub Initialize
Set FSO = CreateObject("Scripting.FileSystemObject")
Set initFolder = FSO.GetFolder("C:\")
Set SubFolders = initFolder.Subfolders
Set Files = initFolder.Files
Set TextFile = FSO.CreateTextFile("C:\RecurseTest.txt")'This will create a
text file on your C: drive

If SubFolders.Count > 0 Then
Forall x In SubFolders
TextFile.WriteLine(x.Path)
Recurse(x)
End Forall
End If
TextFile.Close
End Sub

Function Recurse(CurFolder As Variant)
Dim Sub_RFolders As Variant
Dim RFolders As Variant
Set RFolders = CurFolder.SubFolders

Forall y In RFolders
Set Sub_RFolders = y.SubFolders
TextFile.WriteLine(y.Path)
If Sub_RFolders.Count > 0 Then
Recurse(y)
End If
End Forall
End Function

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.