I need to copy and overwrite a number of files programmatically and I'd like
to know how to modify the following code from technet to use an array of
"copy from" names.

'starting point
Const OverwriteExisting = TRUE

Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\FSO\ScriptLog.txt" , "D:\Archive\", OverwriteExisting

'end starting point

'start pseudo code
dim ary(3)

ary(1) = "C:\FSO\ScriptLog1.txt"
ary(2) = "C:\FSO\ScriptLog2.txt"
ary(3) = "C:\FSO\ScriptLog3.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
For i = 1 to 3
' something on the lines of:
objFSO.CopyFile "" & ary(3) &"" , "D:\Archive\", OverwriteExisting
Next

'end pseudo code

Any help will be greatly appreciated.

Thanks,
Raul

Re: Script that uses an array of file names to copy and overwrite file by Gino

Gino
Sat Jan 27 21:41:45 CST 2007

dim ary(3)
Const OverwriteExisting = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")

ary(1) = "C:\FSO\ScriptLog1.txt"
ary(2) = "C:\FSO\ScriptLog2.txt"
ary(3) = "C:\FSO\ScriptLog3.txt"

For i = 1 to 3
objFSO.CopyFile ary(i) , "D:\Archive\", OverwriteExisting
Next

Set objFSO = Nothing


"Raul" <raul@nothere.com> wrote in message
news:50B609E4-82C5-49E9-9E67-27355ADD1984@microsoft.com...
>I need to copy and overwrite a number of files programmatically and I'd
>like
> to know how to modify the following code from technet to use an array of
> "copy from" names.
>
> 'starting point
> Const OverwriteExisting = TRUE
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> objFSO.CopyFile "C:\FSO\ScriptLog.txt" , "D:\Archive\", OverwriteExisting
>
> 'end starting point
>
> 'start pseudo code
> dim ary(3)
>
> ary(1) = "C:\FSO\ScriptLog1.txt"
> ary(2) = "C:\FSO\ScriptLog2.txt"
> ary(3) = "C:\FSO\ScriptLog3.txt"
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> For i = 1 to 3
> ' something on the lines of:
> objFSO.CopyFile "" & ary(3) &"" , "D:\Archive\", OverwriteExisting
> Next
>
> 'end pseudo code
>
> Any help will be greatly appreciated.
>
> Thanks,
> Raul
>