26

I need find a file in Windows under command line, but receive results as a table. Similar to windowed version of find, where we have last column, displaying location.

dir /s doesn't match this requirement, because it enters each directory and reports this in separate header, leaving file list as usual.

4
  • Probably not possible using the command line. You could build something using PowerShell.
    – Seth
    Commented Feb 17, 2017 at 11:30
  • Would this do: Get-ChildItem -ErrorAction SilentlyContinue -Recurse c:\ -Filter "filetosearch.exe" | select Directory Commented Feb 17, 2017 at 13:40
  • 1
    Maybe: Get-ChildItem -ErrorAction SilentlyContinue -Recurse c:\ -Filter "filetosearch.exe" | select Directory,Name,LastWriteTime | format-table etc... Commented Feb 17, 2017 at 13:47
  • How about DIR /A-D /B /S would that suffice for the need? Commented Feb 17, 2017 at 13:48

3 Answers 3

40

You can use where.exe

where /r c:\windows ntoskrnl.exe

or, with wildcards:

where /r c:\windows ntoskr*
1
  • 3
    This is an excellent solution. I have used Windows' where as Unix which equivalent for a long time, but I did not know until now that is also (somewhat) capable to replace find .
    – jschreiner
    Commented Nov 19, 2020 at 15:43
23

If the headers are the only problem in your case, use the /B switch. This returns a list of all files matching the filename along with their location.

dir filename.ext /S /B
-2

dir filename.* /S /B

Finds all the matches for the string filename. Displays src and include files

2
  • 2
    Can you explain why you think that answers the question?
    – RalfFriedl
    Commented Sep 17, 2019 at 5:18
  • 3
    Duplicate of answer given over a year ago by @Pradeep, above
    – RufusVS
    Commented Dec 17, 2019 at 22:46

You must log in to answer this question.

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