Re: script that uses an array copy an array of file names by raul
raul
Thu Jan 25 22:47:00 CST 2007
Adding the chr(34) results in a "bad file name or number error".
I think the syntax in your original post was correct. I'm wondering if I
have a security setting that is creating the "permission denied" error.
By the way, I tried:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\FSO\ScriptLog1.txt" , "D:\Archive\", OverwriteExisting
and also got the same "permission denied" error.
Thanks,
Raul
"joseomjr@gmail.com" wrote:
> Try this.
> objFSO.CopyFile Chr(34) & arr1(i) & Chr(34), "D:\Archive\",
> OverwriteExisting
>
> On Jan 25, 7:57 pm, Raul <r...@nothere.com> wrote:
> > I'm getting a VBScript runtime error (permission denied).
> >
> > The actual path and names are longer and do contain spaces. Also I'm Using
> > an underscore for a line continuation symbol.
> >
> > Thanks,
> > Raul
> >
> > "joseo...@gmail.com" wrote:
> > > Dim arr1(2)
> >
> > > arr1(0) = "C:\FSO\ScriptLog1.txt"
> > > arr1(1) = "C:\FSO\ScriptLog2.txt"
> > > arr1(2) = "C:\FSO\ScriptLog3.txt"
> >
> > > Set objFSO = CreateObject("Scripting.FileSystemObject")
> > > For i = 0 to 2
> > > ' something on the lines of:
> > > objFSO.CopyFile arr1(i), "D:\Archive\", OverwriteExisting
> > > ' WScript.Echo arr1(i), "D:\Archive\", OverwriteExisting
> > > Next
> >
> > > On Jan 25, 7:04 pm, Raul <r...@nothere.com> wrote:
> > > > 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
>
>