35

I don't know the full path to a folder, just the folder name. I would like to find everywhere where this folder is using CMD. Is there a command that does this?

I am looking for an equivalent to *nix's:

find . -name <folder name> -type d

Is there anything like that in Windows CMD? I know dir /s ...

3 Answers 3

41

So at the root of the drive:

dir <Folder Name> /AD /s
5
  • 4
    /A- Displays files with specified attributes. D-May the attribute be Directories /s - Displays files in specified directory and all subdirectories.
    – nanospeck
    Commented Jun 26, 2014 at 2:15
  • Is it possible to extend this search to hidden subfolders as well?
    – Luke
    Commented Nov 10, 2015 at 22:16
  • It is searching only in C drive
    – pyd
    Commented Nov 28, 2017 at 4:31
  • 1
    Then tell it to search in whichever drive you want.
    – EBGreen
    Commented Nov 28, 2017 at 15:28
  • 1
    To get a compact listing of all directory location, you can add /B, like this: dir <Folder Name> /AD/S/B
    – Matt Roy
    Commented Feb 7, 2019 at 15:41
15
  1. switch to the root-search-folder (e.g. C:)
  2. type dir /S /P <file or foldername> (/P pauses after each screenful of information)

If you'd like a list of all occurances of a specific filename, you can simply redirect the output to a file:

dir /S <filename> > c:\results.txt

You can also narrow down your results by using the /A switch of the dir command. If you'd like to only list directories, you can append /AD to your command:

dir /S /P <filename> /AD

Other possibilities are:

 /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

If you'd like to know more about the dir command, just type dir /?into your cmd.

2
  • np, maybe worth an upvote? ;)
    – wullxz
    Commented May 23, 2012 at 20:19
  • Definitely worth it, but my rep isn't high enough on this sub-SOF hahaha Commented May 23, 2012 at 20:24
0
dir /S /b

/S searches recursively

/b removes the additional directory metadata from the search results, so you get a nice clean list of files

3
  • This doesn't work correctly. See i.imgur.com/X0MCR1p.png
    – DavidPostill
    Commented Jul 2, 2018 at 9:43
  • @DavidPostill - yes it does, your pictyure shows you asking for the contents of 'test', which contains the single item 'test' (at least that's all we can see in it), and the /b flag removes the heading metadata. Without the /b flag, the root directory is also shown
    – Krakkos
    Commented Jul 3, 2018 at 10:21
  • My point stands. Using \b omits f:\test from the listing. It returns one file when there are two. Therefore the answer is wrong.
    – DavidPostill
    Commented Jul 3, 2018 at 10:35

You must log in to answer this question.

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