Easiest way to copy several files?

R

Rob Meade

Hi all,

I have an application writing directories as and when needed, there is a
template directory which contains 5 files that I need to copy into each new
directory. I initially looked at the copyFolder method, but I dont want to
copy the entire folder 'into' the directory that I've just created only the
content.

I have therefore looked at the copying of a file method...

Would I be better :

a) Creating an object for each of the 5 files and copying them across one by
one..

eg. Set File = FSO.GetFile(strWebsiteRootPath & "\myfile.txt")

b) Not creating the directory initially as I am currently doing, then just
copy the entire template directory to the new location (which will be the
same 'level' as the template directory) - and I guess somehow rename it?

c) Some other option that I've not thought of :eek:)

Any help is appreciated,

Regards

Rob
 
S

Steven Burn

Try this;

Dim FSO
Dim Files
Dim Fil
Dim Strpath
Dim StrDest
Strpath = ../some_path

StrDest ../some_other_path

Set FSO = Server.CreateObject("Scripting.FileSystemObject")

Set Files = FSO.GetFolder(Server.MapPath(StrPath)).Files

For Each Fil in Files
FSO.CopyFile Fil StrDest
Next

Set File = Nothing
Set Files = Nothing

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
I know I'm probably wrong, I just like taking part :eek:)
 
R

Rob Meade

...
For Each Fil in Files
FSO.CopyFile Fil StrDest
Next

Hi Steve,

Many thanks for your reply. I am currently getting an error on the
FSO.CopyFile line above.

Microsoft VBScript runtime error '800a01c3'
Object not a collection: 'Fil'
/parasolit/admin/administrators/mgmt-websites-mainbody-add.asp, line 441

Would I need to do a mappath to Fil - or does it know to look in the current
directory etc?

Regards

Rob
 
S

Steven Burn

hehe, knew I'd forgotten something... glad you got it sorted ;o)

--
Regards

Steven Burn
Ur I.T. Mate Group CEO
www.it-mate.co.uk

Disclaimer:
I know I'm probably wrong, I just like taking part :eek:)
 
R

Rob Meade

...
hehe, knew I'd forgotten something... glad you got it sorted ;o)

hehe- thanks Steve - nice to have to do a little bit of work myself :eek:)

Thanks again for your help...

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top