Click to See Complete Forum and Search --> : Need to make multiple copies of file with generated filenames


Exceter
February 2nd, 2006, 09:28 PM
Hi,

I need a VBS script which makes copies of file, the filenames I think the best (and only :) )
way are should be generated.

it is very long time i have not programmed, have forgotten lots of.
could you help please. :rolleyes:

PeejAvery
February 3rd, 2006, 09:18 AM
Since you didn't specify how you want your filenames to be generated I will leave that to you. This should help you out. Now you just have to loop through it.

Dim OldPath as String
Dim NewPath as String
Dim OldName as String
Dim NewName as String
Dim FileExtension as String

OldPath = "C:\Windows\"
NewPath = "C:\Winnt\"
OldName = "docname"
NewName = "newdocname"
FileExtension = ".txt"

Dim fso
set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile OldPath & OldName & FileExtension, NewPath & NewName & FileExtension
set fso = nothing

MsgBox "Done!"

Exceter
February 3rd, 2006, 10:06 PM
Thanx.
it helped me. I found the solution.

PeejAvery
February 4th, 2006, 12:49 AM
Thanx.
it helped me. I found the solution.
You're welcome.