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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i handle a movefile error

Status
Not open for further replies.

bookouri

IS-IT--Management
Joined
Feb 23, 2000
Messages
1,464
Location
US
I want to move every file in a directory to another directory, I can use
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile "c:\temp\source\*.*", "c:\temp\dest\"
but if the file already exists the script fails and nothing gets moved. How can I force the script to overwrite the existing file no matter what?

any suggestions would be appreciated...
 
You may use the CopyFile method like this:
Code:
fso.CopyFile "c:\temp\source\*.*","c:\temp\dest\",True
and then the DeleteFile method.

Hope This Help
PH.
 
Actually thats what I ended up doing. Im still having a problem though... when I do a copyfile or movefile the files dont really get copied/moved to the mapped drive destination. They just disappear into never never land for some reason.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top