Sub-Directories Check For Existance And Add If It Doesn't Already Exist

This is a neat little function that checks to see if a declared subdirectory
exists and if is doesn't then it creates it. It assumes that the parent
directory exists, so if in doubt then call the function several times starting
at the root.

This is a useful function if, like me, you want to control the detaching of
documents so that they are placed using script in the same sub directory on all
user's machines
To call the function:

CheckForCreateDirectory("c:\notes\data\attachments")


The Function itself:

Function CheckForCreateDirectory(DirPath As String)
'This function checks for a subdirectory given the parent, and if it doesn't
exist it creates it

'Extract the different elements of the full path
DirName=DirPath
Continue=False
Do While continue=False
If Instr(DirName,"\") Then
DirName=Right(DirName,Len(DirName)-Instr(DirName,"\"))
Else
Continue=True
End If
Loop
ParentDirPath=Left(DirPath,Len(DirPath)-Len(DirName))

'Check for directory and add if it doesn't exits
CheckDir = Dir$(ParentDirPath,16)
CheckDirFlag=False
Do While CheckDir <> ""
If Ucase(CheckDir) = Ucase(DirName) Then
CheckDirFlag = True
End If
CheckDir = Dir$()
Loop
If CheckDirFlag=False Then
Mkdir DirPath
End If
End Function

Dig Deeper on Lotus Notes Domino Administration Tools

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close