set fso = CreateObject("Scripting.FileSystemObject")
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
moveToDrive = "D:\"
set failures = fso.CreateTextFile(moveToDrive & "failures.txt")
Set objFolder = fso.GetFolder(sCurPath)
ShowSubFolders objFolder, fso
WScript.Echo "The operation has successfully completed."
Sub ShowSubFolders(objFolder, fso)
On Error Resume Next
fso.CopyFolder objFolder, moveToDrive
Set colFiles = objFolder.Files
For Each objFile In colFiles
objFilePath = objFile.Path
objFileName = objFile.Name
strLen = len(objFilePath)
moveToLocation = right(objFilePath, (strLen - 3))
wscript.echo moveToDrive & moveToLocation
fso.CopyFile objFile, "D:\Documents and Settings\t104ahe\Desktop\Copy script test\" & objFileName
fso.CopyFile objFile, moveToDrive & moveToLocation
If Err.number <> 0 Then
failures.WriteLine "Error copying " & objFile.Path
End if
Err.Clear
On Error GoTo 0
Next
Set colFolders = objFolder.SubFolders
For Each objSubFolder In colFolders
ShowSubFolders objSubFolder, fso
Next
If Err.number <> 0 Then
failures.WriteLine "Error copying " & objFile.Path
End if
Err.Clear
On Error GoTo 0
End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE