Hi, all,
I’m having a problem with some LotusScript code which I’m using to copy files from one directory to another. I’m going to paste the relevant segment, then explain what it does and what the problem is. Hopefully someone can help me come up with a workaround.
Forall X In filelist
If Not X = “” Then
If Dir$("C:\" + X + ".*") = "" Then
Messagebox X + ".* could not be found!"
Else
allfiles = Dir$("C:\" + X + ".*")
While Not allfiles = ""
If (Dir$("C:\DIR\" + allfiles) <> "") Then
<do whatever>
Else
Filecopy "C:\" & allfiles, "C:\DIR\" & allfiles
allfiles = Dir$
End If
Wend
End If
End If
End Forall
filelist is an array of file names. First it tests to ensure the file can be found, and if so, it then creates allfiles, which is another array. For every file name in filelist, there are possibly two actual files with different extensions (i.e. fakefile.a and fakefile.b). Before it copies the files, I test to see if the same file is already in the destination folder ("If (Dir$("C:\DIR" + allfiles) <> “”) Then). This is actually the problem. Because I have to use Dir here, it corrupts my next call to Dir when I run “allfiles = Dir$”, which causes an illegal function call.
To summarize, I need to copy multiple files with the same name, different extensions. Before copying, I need to check the destination to see if the file already exists. How can I accomplish both of these? Within a loop (as required by use of the * wildcard). Thanks.
Patrick