Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copying multiple files 1

Status
Not open for further replies.

FJAY

Programmer
Apr 23, 2003
106
CA
I try to copy multiple files from one directory to another using the filecopy statements like this"

filecopy "\\b\lab\orders\*.*", "\\b\lab\com-orders\"

How can I copy multiple files from one directory to another directory i.e. directory A to B. Thanks.
 
This method uses the FSO but you could easily modify it to use FileCopy. I prefer FSO because of the overwrite option.

' Add a reference to Microsoft Scripting Runtime
Dim fso As New FileSystemObject, fil As File, ts As TextStream
Set fso = CreateObject("Scripting.FileSystemObject")
Dim MyFileName As String
MyFileName = Dir("C:\17410sd\*.*")
Do While MyFileName <> vbNullString
fso.CopyFile &quot;C:\17410sd\&quot; & MyFileName, &quot;C:\&quot; & MyFileName, False
MyFileName = Dir
Loop
MsgBox &quot;File Copy Complete!&quot;, vbInformation

Swi
 
Swi - Thanks...this works fine both ways but an error occurs if the filename already exist. Thanks
 
Swi - never mind....I'm very dumb....the overwrite should be set to true. Thanks.
 
How can i create a text file?
I would like the code for this.

 
There are many ways to create a text file. Here is an example:

Open &quot;YOUR FILE NAME.txt&quot; For Output As #1
Print #1, &quot;This is a test&quot;
Close #1

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top