FileCopy and Dir

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

Subject: FileCopy and Dir

Why not do another loop first to check what files exist on the destination? Keep their names in memory and do the check on this list.

Subject: RE: FileCopy and Dir

I can’t believe how easy that was. For whatever reason, not sure why I didn’t think to create an array of all the actual file names first, then just check against that. Thanks!

Patrick

Subject: FileCopy and timestamp

Is there any workaround to prevent the FileCopy function from updating the timestamp of the new file it creates in the destination source? As is, that’s pretty useless if you want an actual copy of the file. If there is no LotusScript solution, I may have to call an external script to do the actual copy, but I would definitely prefer to avoid that.

Patrick

Subject: RE: FileCopy and timestamp

I don’t know of any way to keep the old timestamp with FileCopy.

Issueing an external DOS-command is no big deal. You can just call cmd.exe /c with the correct parameter directly from LS using the Shell-command.

Subject: RE: FileCopy and timestamp

Works perfectly! Thanks, Rob!

Patrick