How to Search for and Delete Empty Folders

Written by maya austen
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Search for and Delete Empty Folders
Locating and deleting the empty folders on your computer. (trade,market and balance folders on the pc screen image by Alexey Klementiev from

There are a number of software applications which can locate and delete the empty folders stored on your computer. However, you may not what to install another application onto your system--especially one that you likely won't use very much. It involves a little more work, but you can search for and delete the empty folders on your computer by using a simple code to create a BAT file that lists all of the folders on your computer. A few edits to this file will make it execute a command that will delete any empty folders.

Skill level:


  1. 1

    Open the DOS Command Prompt by clicking "Start," pointing to "All Programs" (or "Programs"), pointing to "Accessories" and clicking "Command Prompt."

  2. 2

    Type the following command line at the C prompt: DIR /AD/B/S | SORT /R > EMPTIES.BAT. (to type the | vertical line symbol, press "Shift" plus "\"). Be sure to type the command as is, including the spaces. This command will create a BAT file that lists, in reverse order, all of the folders on your computer's hard drive.

  3. 3

    Conduct a search for the "empties.bat" file you just created. The file is likely saved in the "C:\Documents and Settings\CurrentUserName" folder (in Windows XP), or "C:\User\CurrentUserName" folder (in Vista and Windows 7). Run the search to be sure, then make a note of the file location.

  4. 4

    Open Microsoft Word, then open your empties.bat file within Word.

  5. 5

    Go to the "Edit" menu and select "Replace" to open the Find and Replace dialogue box. In the "Find what" field type: ^p (Shift+6, p). In the "Replace with" field type: "^prd "(open quotation mark, shift+6, prd SPACE end quotation mark). Click "Replace All."

  6. 6

    Edit the file. Each file name should now be encased in quotation marks, and preceded by the command rd (which stands for remove directory). For example: ... rd "C:\Documents and Settings\ UserName\Local Settings\Temporary internet Files\Content.Word" rd "C:\Documents and Settings\UserName\Local Settings\Temporary internet Files\Content.MSO" ... Look over the document to ensure that this pattern holds throughout. Edit where needed.

  7. 7

    Save the changes to the file. Go to the "File" menu and select "Save. You may receive a prompt which states that the file, "...may contain features that are not compatible with Plain Text format. Do you want to save the document in this format?" Click "Yes."

  8. 8

    Launch the empties.bat file. Open the folder that contains your empties.bat file. Right-click on the file and select "Open" from the shortcut menu. This BAT file will now try to perform the remove directory (rd) command on each folder. The rd command will fail for any folder that contains a file(s).

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.