Hi experts
I need fix this dilemma i have files pdf extension in folder ZZ and contains some subfolders inside the folder ZZ when move to folder MMM just move files from subfolders and ignores the files are existed in folder ZZ .
here is the code
Sub r()
Dim Fso As Object, objFolder As Object, objSubFolder As Object, ct As Long
Dim sourcePath, destPath As String
Dim FileInFolder As Object
sourcePath = "C:\Users\PC WORLD\Desktop\zz\" 'Change path and folder name to suit
destPath = "C:\Users\PC WORLD\Desktop\mmm\" 'Change path and folder name to suit
Set Fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = Fso.GetFolder(sourcePath)
For Each objSubFolder In objFolder.subfolders
For Each FileInFolder In objSubFolder.Files
If FileInFolder.Name Like "*.pdf*" Or FileInFolder.Name Like "*PDF*" Then
ct = ct + 1
FileInFolder.Move destPath
End If
Next FileInFolder
Next objSubFolder
If ct > 0 Then
MsgBox ct & " pdf files have been moved"
Else
MsgBox "No pdf files found in the source folder"
End If
End Sub