Please try the following commands
List all files in the current directory & subdirectories
dir /b/s *.txt
The above command searches for all txt file in the directory tree.
But as windows is started naming directories as .nuget
,.vscode
it also comes with the command above.
In order to avoid this and have a clean list use /a:-d
filter as
dir /a:-d /b/s
Before using it just change the directory to root using
cd/
There is one more hacky command to do the same
for /r %f in (*) do @echo %f
Note: If you miss the @echo
part in the command above it will try to execute all the files in the directories, and the /r
is what making it recursive to look deep down to subdirectories.
Export result to text file
you can also export the list to a text file using
dir /b/s *.exe >> filelist.txt
and search within using
type filelist.txt | find /n "filename"
If you are looking for files with special attributes, you can try
List all Hidden Files
dir /a:h-d /b/s
List all System Files
dir /a:s-d /b/s
List all ReadOnly Files
dir /a:r-d /b/s
List all Non Indexed Files
dir /a:i-d /b/s
If you remove the -d
from all commands above it will list directories too.
Using where
in windows7+:
Although this dir command works since the old dos days but Win7 added something new called Where
where /r c:\Windows *.exe *.dll
will search for exe & dll in the drive c:\Windows as suggested by @SPottuit you can also copy the output to the clipboard with
where /r c:\Windows *.exe |clip
just wait for the prompt to return and don't copy anything until then.
Page break with more
If you are searching recursively and the output is big you can always use more
to enable paging, it will show -- More --
at the bottom and will scroll to the next page once you press SPACE
or moves line by line on pressing ENTER
where /r c:\Windows *.exe |more
For more help try
where/?