FileCopy

A

Andibevan

Hi All,

Can File copy be used with the extension *.* in order to copy the contents
of folders or does another method need to be used?

i.e. will this work?

Filecopy "C:\temp1\*.*", "C:temp2\*.*"

Ta

Andi
 
A

Andibevan

I presume I need to use the filesystemobject.copyfolder method - would this
be fast enough for transfering 1/2gb of files or is there a quicker way?

Hi All,

Can File copy be used with the extension *.* in order to copy the contents
of folders or does another method need to be used?

i.e. will this work?

Filecopy "C:\temp1\*.*", "C:temp2\*.*"

Ta

Andi
 
A

Alok

As you correctly figured, Filecopy does not work with wildcards. I have not
had any speed issues with FileSystemObject.
Alok Joshi
 
P

Peter_A_M (NL)

Hello again,

Maybe you could make use of the Dir function, which returns the name of the
file when it exists or an empty string when not.

Especially its use in loops I find very practical (Dir without argument
returns
the next filename within the given range):

PathFrom = "c:\Temp1"
PathTo = "c:\Temp2"

varTest = Dir(PathFrom)

Do Until varTest = ""
From = PathFrom + "\" + varTest
To = PathTo + "\" + varTest
FileCopy From, To
varTest = Dir
Loop

It works fine, but how time consuming it is in your case, I don't know!

Maybe this could be of help to you,
Greetings,


PS:
Dir may be used with just a path or with wildcards, e.g.
"c:\TestFolder\a*.doc" ,
so you even could make selections this way.
 
P

Peter_A_M (NL)

So sorry!

Almost always thoroughly testing, but not this time...
so at least two mistakes!

Here the correct code

PathFrom = "c:\Temp1" ' both paths should exist
PathTo = "c:\Temp2"

varTest = Dir(PathFrom + "\*.*") ' filename [wildcards allowed] necessary

Do Until varTest = ""
FileFrom = PathFrom + "\" + varTest
FileTo = PathTo + "\" + varTest ' now a better variable name!
FileCopy FileFrom, FileTo
varTest = Dir
Loop


Greetings again,
Peter
 
A

Andibevan

Thanks to all for your help on this one.

Regards

Andi

I presume I need to use the filesystemobject.copyfolder method - would this
be fast enough for transfering 1/2gb of files or is there a quicker way?

Hi All,

Can File copy be used with the extension *.* in order to copy the contents
of folders or does another method need to be used?

i.e. will this work?

Filecopy "C:\temp1\*.*", "C:temp2\*.*"

Ta

Andi
 

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

Top