Skip to content
Home » How to locate empty directories in windows using CMD

How to locate empty directories in windows using CMD

To find empty directories in Windows, by using the Command Prompt, we can use the following command,

  1. This command will search for all directories (/ad for current dir) in the current directory and its subdirectories (/s for subdir)
  2. Display their names (/b). The findstr the command is used to filter the output and only show directories (denoted by the “:” pattern).
Locate empty directories in windows using CMD
How to locate empty directories in windows using CMD?

Note that this command will only show directories that are completely empty (i.e., they do not contain any files or subdirectories).

If we want to include directories that contain empty subdirectories, we can use the following command instead,

The above command will search for all directories in the current directory with its subdirectories.

Locate empty directories in windows and store the command

To save the list of empty directories to a text file, we can redirect the output of the command to a text file using the > operator, like this,

This will save the list of empty directories to a text file called empty_dirs.txt in the current directory.

We can also specify a specific directory to search for empty directories by replacing . with the path to the directory, like this:

The above command will search for empty directories in the C:\my_directory directory and save the results to the empty_dirs.txt file.

Also Read:

Was this article helpful?
YesNo

Leave a Reply

Your email address will not be published. Required fields are marked *