How to Batch Delete All Folders with a Specific Name in Your Outlook

If you would like to delete all the folders with a specific name, you can use the way introduced in this article. It can help you batch accomplish it via VBA.

At times, you may need to quickly locate all the folders that have a specific name and delete them. For instance, you’ve created folders named as a certain contact’s full name. Now, you delete this contact from your Outlook. In the same time, you may also want to batch delete these folders. It is troublesome to find and delete them one by one. Hence, in the followings, we will introduce a method to batch delete them in one go.

Batch Delete All Folders with a Specific Name

  1. At first, launch Outlook program.
  2. Then, get access to VBA editor with reference to “How to Run VBA Code in Your Outlook“.
  3. Next, copy and paste the following VBA code into a module.
Dim strFolderName As String

Sub BatchDeleteAllFoldersSpecificName()
    Dim objOutlookFile As Outlook.Folder
    Dim objFolder As Outlook.Folder
    Dim lTotalCount As Integer
    'Enter the specific name
    strFolderName = InputBox("Enter the specific folder name:", , "Test")
    If strFolderName <> "" Then
       Set objOutlookFile = Outlook.Application.Session.PickFolder
       If Not (objOutlookFile Is Nothing) Then
          lTotalCount = 0
          For Each objFolder In objOutlookFile.Folders
              If objFolder.Name <> "Deleted Items" Then
                 Call ProcessFolders(objFolder, lTotalCount)
              End If
          strMsg = lTotalCount & " folders have been deleted!"
          MsgBox strMsg, vbInformation + vbOKOnly
      End If
    End If
End Sub

Sub ProcessFolders(ByVal objCurFolder As Outlook.Folder, ByRef lCount As Integer)
    Dim objSubfolder As Outlook.Folder
    'Delete the folder of the specific name
    If objCurFolder.Name = strFolderName Then
       lCount = lCount + 1
    End If
    'Process all subfolders recursively
    On Error Resume Next
    If objCurFolder.Folders.Count > 0 Then
       For Each objSubfolder In objCurFolder.Folders
           Call ProcessFolders(objSubfolder, lCount)
    End If
End Sub

VBA Code - Batch Delete All Folders with a Specific Name

  1. After that, move cursor in the first subroutine.
  2. Later, click “Run” icon in the toolbar.
  3. Subsequently, in the small popup dialog box, input the specific folder name to be found.Specify Folder Name
  4. Then, in the “Select Folder” dialog, select the specific Outlook file.Select Outlook Data File
  5. When macro finishes, you’ll get a message which prompts of the count of the deleted folders, as shown in the following screenshot.Count of Folders That Have Been Deleted
  6. Now, you can check the folder list. All the folders with the specific name have been deleted (moved to “Deleted Items” folder).Batch Deleted Folders with a Specific Name

Refrain Outlook from Corruption

Outlook is vulnerable, which has been an unquestioned fact. Therefore, if you are not willing or ready to come across Outlook data corruption, you have to back up your Outlook data files regularly. Besides, in reality, it is essential to keep a robust Outlook PST repair tool in vicinity, like DataNumen Outlook Repair. It is able to recover PST data with effortless ease in the event of Outlook corruption.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including damaged mdf and outlook repair software products. For more information visit

Comments are closed.