36

Is there a command on the Windows command-line that can list hidden folders?

I've tried dir -a:dh but that doesn't work for me.

3 Answers 3

37

Use the following command:

dir /a:hd C:\folder\

The difference between what you were typing and this command is that you were using a - to indicate the switch, not a /. In most windows command line applications, this doesn't matter, but in the case of the dir command, you must use a slash, not a dash.

The /a switch changes which attributes are displayed. h shows hidden files and d shows just directories. Make sure you keep the trailing slash on the end of the folder path. I just tested, and it worked fine.

5
  • What's the point of the : character in /a:hd? Omitting it and simply doing dir /ah seems to work well....
    – Pacerier
    Commented Apr 25, 2015 at 20:24
  • How can I make dir display all files folders and the attributes of each item?
    – Royi
    Commented Jun 29, 2017 at 18:33
  • 2
    I get "dir : Cannot find drive. A drive with the name '/a' does not exist." when I run "dir /a:hd"
    – geronimo
    Commented Apr 15, 2022 at 14:30
  • It looks like Royi and Pacerier might be in Powershell prompts? When I open up a cmd.exe it works as advertised (and doesn't work in, eg, a VS Code Powershell terminal). More info. cmd /r dir /a is a neat workaround.
    – ruffin
    Commented Jun 14, 2022 at 19:13
17
  • dir/a should show hidden folders.
  • dir /a:d shows all directories.
  • dir /a:h shows all hidden files.

Try dir /adh (without the colon) to combine.

3
  • And "dir /ad-h" shows only non-hidden directories, like "dir". Commented Apr 30, 2011 at 11:40
  • 1
    Why the down vote? The answer is correct. Commented Apr 30, 2011 at 17:26
  • Btw if we only do dir /ad (as opposed to dir /ad-h and dir /adh), what's the default h behavior?
    – Pacerier
    Commented Apr 25, 2015 at 20:29
7

To list all files and folders, including hidden and system ones, use dir with /a flag:

dir /a C:\
1

You must log in to answer this question.

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