>It does not seem to work as the documentation suggests (maybe I'm misunderstanding the documentation). That is, if the destination folder exists it copies the files into the destination folder unless there are files of the same name in the destination folder.
I hope that is not exact quotation from the documentation.
Leaving the possibility of wildcard for multiple folder copying, suppose the srcfolder and tgtfolder like this.
[tt]
srcfolder="d:\abc\def" 'a folder existing
tgtfolder="d:\pqr\stu" 'without trailing backslash
[/tt]
The documentation suggests
[a] the If condition being met, error will be triggered (this is obvious).
[tt] if fso.folderexists(tgtfolder) then
fso.copyfolder srcfolder,tgtfolder,false
end if[/tt]
If condition being met, error will be triggered as well, ie, if there is a "file" of the name of tgtfolder, here d:\pqr\stu, a perfectly valid file name, disregard overwrite being true or false: meaning you cannot overwrite a "file" from copyfolder operation even the 3rd parameter is set to true, not to say set to false.
[tt] if fso.[blue]file[/blue]exists(tgtfolder) then
'any of these will be error out
fso.copyfolder srcfolder,tgtfolder,false
'fso.copyfolder srcfolder,tgtfolder 'implicitly or explicitly overwrite true[/tt]
[b.1] (This note is targetted to the quote in the thread.) If the tgtfolder exists already, the name of the "files" [red]within[/red] that folder does not matter. They will be clear out in any case. The obvious way to verify it is to run twice the copyfolder.
[tt]
fso.copyfolder srcfolder,tgtfolder,true
fso.copyfolder srcfolder,tgtfolder,true 'no error
[/tt]
[blue]attachment [excerpt from documentation][/blue]
[tt]
If destination does not exist, the source folder and all its contents gets copied. This is the usual case.
If destination is an existing file, an error occurs.
If destination is a directory, an attempt is made to copy the folder and all its contents. If a file contained in source already exists in destination, an error occurs if overwrite is false. Otherwise, it will attempt to copy the file over the existing file.
If destination is a read-only directory, an error occurs if an attempt is made to copy an existing read-only file into that directory and overwrite is false.
An error also occurs if a source using wildcard characters doesn't match any folders.
[/tt]