|
-
Sep 28th, 2002, 01:39 PM
#1
Thread Starter
Frenzied Member
Just Move a directory, into an exsisting directory, replacing all files that exsist .
Just Move a directory, into an exsisting directory, replacing all files that exsist , if i am moving the directory to, and the file already exsists there,
Just like in Windows Explorer,
How do i do this?
-
Sep 28th, 2002, 04:35 PM
#2
PowerPoster
check out the File System Object
-
Sep 30th, 2002, 04:01 AM
#3
Frenzied Member
You need some code that does:
For all Files in the Directory:
- If the File is in the target directory, delete it.
- Copy the File to the target Directory.
Loop until end of Directory.
Use the FSO for the "all files in directory".
-
Sep 30th, 2002, 12:18 PM
#4
Thread Starter
Frenzied Member
Originally posted by phinds
check out the File System Object
wheres the FSO?
-
Sep 30th, 2002, 12:24 PM
#5
PowerPoster
Just include a reference to "Microsoft Scripting Runtime"
-
Sep 30th, 2002, 03:40 PM
#6
PowerPoster
as wpearsall said, you need a reference to the Scripting Runtime library, and then check out both the on-line help for FSO and also use the object browser to check out all the properties & methods
-
Oct 1st, 2002, 03:44 AM
#7
Frenzied Member
Taking the algorithm:
For all Files in the Directory:
- If the File is in the target directory, delete it.
- Copy the File to the target Directory.
Loop until end of Directory.
You might end up with something like:
VB Code:
strDest = "c:\Test"
strSource = "C:\Temp"
'
' You should check here to make sure DEST and SOURCE actually exist - I dont bother!
'
Set fso = CreateObject("Scripting.FileSystemObject")
Set fsoFolder = fso.GetFolder(strSource)
Set fsoFiles = fsoFolder.Files
For Each strFile In fsoFiles
strFileName = Mid(strFile, InStrRev(strFile, "\") + 1)
If Len(Dir(strDest & "\" & strFileName)) <> 0 Then
Kill (strDest & "\" & strFileName)
End If
FileCopy strSource & "\" & strFileName, strDest & "\" & strFileName
Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|