How to check a folder exist with user name in share drive

Hi I have share drive with the folder each user last name i.e

\Citrixuser\HR\perm\john\application\notesdata

\Citrixuser\HR\perm\Frank\application\notesdata

\Citrixuser\HR\perm\Willim\application\notesdata

I have a agent will first find the user folder with his name, if user folder is there then detach a files. Here is script but not sure how to check with each user name folder.

Error Goto Errhandler

Dim session As New notessession

Dim view As notesview

Dim doc As NotesDocument

Dim db As NotesDatabase 'current database

Dim filepathb As Variant

Dim filepatha As Variant

Dim userfoler As Variant

Dim fullpath As Variant

Set db = session.CurrentDatabase

Set view = db.GetView(“Clientinfo”)

Set doc = view.GetFirstDocument

filepathb = Evaluate(|@getprofilefield(“ClientProfile”;“FileDetPathBefore”)|)

filepatha = Evaluate(|@getprofilefield(“ClientProfile”;“FileDetPathAfter”)|)

’ above two Evaluate also not returing the values

If Right(filepathb,1) <> "" Then

filepathb = filepathb+""

End If

If Right(filepatha,1) <> "" Then

filepatha = filepatha+""

End If

While Not doc Is Nothing

	userfolder=doc.GetItemValue("CFName")

fullpath=filepathb & userfolder(0) & filepatha

If Dir$(fullpath, 16 ) <>0 Then *** error here file not found

If doc.HasItem(“CNotesId”) Then

Set cnotesid=doc.GetFirstItem(“CNotesId”)

Else

Set cnotesid=doc.CreateRichTextItem(“CNotesId”)

End If

Forall o In cnotesid.embeddedobjects

If o.Type=EMBED_ATTACHMENT Then

Call o.extractfile(fullpath & o.source)

Print fullpath & o.source

End If

End Forall

Else

Print fullpath + " not found"

End If

Set doc=view.GetNextDocument(doc)

Wend

Exit Sub

’ Error handling

Errhandler:

Messagebox “Error” & Str(Err) & ": " & Error$

Exit Sub

End Sub

Thanks

Subject: How to check a folder exist with user name in share drive …

is this scheduled or by an action… trying to see how your are getting the last names.

If this is local by the user, get the user’s last name:

Dim crUser As String

crUser$ = session.CommonUserName

lastName$ = strLeft(crUser$," ")

loop through the perm folder for a match using the lastname variable:

pathName$ = “\Citrixuser\HR\perm*.*”

pathOnly$ = "\Citrixuser\HR\perm"

endpart$ = “\application\notesdata”

folderName$ = Dir$(pathName$, 0)

Do While folderName$ <> “”

fPath$ = pathOnly$+folderName$+endpart$

Print fPath$

from here try to insert the files and use resume in the error handler to continue (as you have).

Wend

if this is run scheduled on the server then you’ll have to search through the last names from person docs or a custom view to get the last names to match against.

if your meaning that you need to check if the files already exist, then first create an array of the files you are going to insert and check to see if the values are present using the same method as matching the folders with the last names.

HTH

Geoff-