All / (switches) in Windows don't have any filter purposes.

I know in Linux it is - (options).

At a Windows command prompt, how can I show only Directories and not Files?

  • Try DIR /B /AD or DIR /B /S /AD and see if one of those are what you're expecting result wise. You can see DIR command switches, etc. from DIR /? to see what options you should pick for your need, syntax, and so on. Are you trying to search for a folder with a specific string in it's name or are you just trying to list all FOLDERS and no files? Does it need to recursively search other subfolders as well? Commented Jul 23, 2016 at 19:06
  • Related answer Commented Jul 23, 2016 at 19:08

2 Answers 2


This is done by filtering by attributes. dir [somedir] /ad will show all entries with the "directory" attribute. It also shows junction points.

From dir /?:

Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
  [/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

              Specifies drive, directory, and/or files to list.

  /A          Displays files with specified attributes.
  attributes   D  Directories                R  Read-only files
               H  Hidden files               A  Files ready for archiving
               S  System files               I  Not content indexed files
               L  Reparse Points             -  Prefix meaning not

From Microsoft's TechNet - Dir:

If you use /a without specifying Attributes, dir displays the names of all files, including hidden and system files.

The following list describes each of the values that you can use for Attributes. Using a colon (:) is optional. Use any combination of these values, and do not separate the values with spaces.

d Directories

h Hidden files

s System files

l Reparse points

r Read-only files

a Files ready for archiving

i Not content indexed files

- Prefix meaning "not"

  • @MichaelIreland No, dir /ad doesn't show files(or in linux language, it doesn't show files that are not directories). Guitar is right. Maybe you're confusing dir with ls, ls with its bollock load of options, has no option to show only directories, but DIR with its few options, does. (with linux one might use the find command, or, ls with grep. But with cmd, and even DOS, simply dir /ad
    – barlop
    Commented Jul 23, 2016 at 18:43
  • 1
    Are you querying a local directory or a remote file system? It's possible that some off-standard NAS systems may return different results. I've used this for years on various versions of Windows, and am currently testing on my local drive with NTFS. cd /d c:\windows followed by dir /ad shows only 85 directories on my Windows 10 system. Commented Jul 23, 2016 at 18:48
  • 1
    Oh ok. It works in real life, but not in this stupid simulation. Good to know. hub.totalsem.com/content/2571#path=2571,2602,2603 First selection. Commented Jul 23, 2016 at 19:48
  • 1
    So IVL, "dir /A:d" or "dir /ad" shows only directories. But not in the sims. Commented Jul 23, 2016 at 19:56
  • @Michael Ireland, For what it's worth, it now appears to work in the simulation as well. We can all rest now. Commented May 31, 2019 at 20:35

Using following command you can list only directory (folder) names without any other information.

dir /B /AD 

/A - allows us to specify the attributes that files need to have to be taken into account.

/B - option that means bare format , i.e. a format that precisely not includes header, size, summary, etc.

/D - for Directories

/AD - list only directories.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .