kracksmith
Technical User
This script searches for anything on the root folder but won't search sub directiories. i know i need to search for recursive but i'm not very good with scripting. Can somebody help in adding the recursion?
Dim sOriginFolder, sDestinationFolder, sFile, oFSO, sAllowedExt, bMove, sMorC
Set oFSO = CreateObject("Scripting.FileSystemObject")
sOriginFolder = "C:\Documents and Settings\administrator.DOMAIN1\Desktop\folder1"
sDestinationFolder = "C:\Documents and Settings\administrator.DOMAIN1\Desktop\folder2"
aAllowedExt = Array("rpt","ppt")
'Set bMove to False to copy, or True to move
bMove = False
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
For Each sFileExtension In aAllowedExt
If UCase(oFSO.GetExtensionName(sFile)) = UCase(sFileExtension) Then
If Not oFSO.FileExists(sDestinationFolder & "\" & oFSO.GetFileName(sFile)) Then
Select Case bMove
Case True
sMorC = "moved"
oFSO.GetFile(sFile).Move sDestinationFolder & "\"
Case False
sMorC = "copied"
oFSO.GetFile(sFile).Copy sDestinationFolder & "\" & oFSO.GetFileName(sFile),True
End Select
End If
End If
Next
Next
WScript.Echo "Copying : All the files have been " & sMorC & " to " & sDestinationFolder
Dim sOriginFolder, sDestinationFolder, sFile, oFSO, sAllowedExt, bMove, sMorC
Set oFSO = CreateObject("Scripting.FileSystemObject")
sOriginFolder = "C:\Documents and Settings\administrator.DOMAIN1\Desktop\folder1"
sDestinationFolder = "C:\Documents and Settings\administrator.DOMAIN1\Desktop\folder2"
aAllowedExt = Array("rpt","ppt")
'Set bMove to False to copy, or True to move
bMove = False
For Each sFile In oFSO.GetFolder(sOriginFolder).Files
For Each sFileExtension In aAllowedExt
If UCase(oFSO.GetExtensionName(sFile)) = UCase(sFileExtension) Then
If Not oFSO.FileExists(sDestinationFolder & "\" & oFSO.GetFileName(sFile)) Then
Select Case bMove
Case True
sMorC = "moved"
oFSO.GetFile(sFile).Move sDestinationFolder & "\"
Case False
sMorC = "copied"
oFSO.GetFile(sFile).Copy sDestinationFolder & "\" & oFSO.GetFileName(sFile),True
End Select
End If
End If
Next
Next
WScript.Echo "Copying : All the files have been " & sMorC & " to " & sDestinationFolder