Set objfso = CreateObject("Scripting.FileSystemObject")
CurrentPath = objfso.getAbsolutePathName("")
Set strFolderPath = objfso.GetFolder(CurrentPath)
'Enter folder path to move the items too
DestFolder = "C:\examplefolder\"
If objfso.folderexists(DestFolder) = false then
objfso.createfolder(DestFolder)
End If
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colSubfolders = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderPath & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder in colSubfolders
GetSubFolders strFolderPath
Next
Sub GetSubFolders(strFolderPath)
Set colSubfolders2 = objWMIService.ExecQuery _
("Associators of {Win32_Directory.Name='" & strFolderPath & "'} " _
& "Where AssocClass = Win32_Subdirectory " _
& "ResultRole = PartComponent")
For Each objFolder2 in colSubfolders2
strFolderPath = objFolder2.Name
Set Folder = objfso.GetFolder(objFolder2.Name)
Set Files = Folder.Files
For each ObjFile in Files
'wscript.echo "Filename: " & objFile
objfso.movefile objFile, DestFolder
Next
GetSubFolders strFolderPath
Next
End Sub