Copy a folder's contents into another folder?
"Claus Busch" wrote:
Consider the following code:
FSO.CopyFolder "C:\MyData" "C:\Backup"
you can also copy the files of this folder to another folder, e.g.:
Sub CopyFile()
Dim objFSO As Object, objFolder As Object, objFile As Object
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.getfolder("C:\MyData")
For Each objFile In objFolder.Files
objFile.Copy "C:\Backup\"
Next
End Sub
Last night, I discovered this solution:
FSO.CopyFolder "C:\MyData" "C:\Backup\MyData"
This will copy MyData into the Backup directory as a
subdirectory. In other words, it seems to be equivalent to
copying and pasting one folder INTO another folder.
I still need to test it a little more and possibly experiment with
the "overwrite" parameter that Gary mentioned earlier.
|