tags:

views:

54

answers:

4

How to find all the *.txt files in any directory(i.e. c:\,d:\ etc.) through command prompt?

+2  A: 
c:
cd \
dir /s *.txt
d:
cd \
dir /s *.txt
Marcelo Cantos
Although it will only search subdirectories, so you'd need to `cd` to the root directory. I also don't know of a way to get it search all drives (i.e. if you're in C:\, it won't search D:\ automatically)
Simon Nickerson
+1 @Simon. Thanks for pointing that out.
Marcelo Cantos
A: 

Try using dir *.txt

Mr Roys
"In any directory," he said. :-)
T.J. Crowder
Oops, somehow I thought he wanted a command which he would run in that particular directory... :|
Mr Roys
+1  A: 

Following will search from root directory and its all accessible sub folders regardless of the folder you currently in.

dir \*.txt /s

or

dir c:\*.txt /s
dir d:\*.txt /s

etc

S.Mark
A: 
setlocal ENABLEEXTENSIONS
FOR %%A IN (a b c d e f g h i j k l m n o p q r s t u v w x y z) DO @call :dumpdrive %%A
echo Done...
goto :EOF
:dumpdrive
FOR /R "%1:\" %%B IN (*.txt) DO @echo.%%~fB
goto :EOF
Anders