Page 1 of 1

Dos function for search files

Posted: 21 Nov 2011 23:52
by programchen
in my C drive, I want to search all files which file name includes string *BEG*.
which command I should use?

also I want to find the directory name that has file name including string *BEG*.
which command I should use?

thanks

Re: Dos function for search files

Posted: 22 Nov 2011 00:13
by Ed Dyreen
'
try:

Code: Select all

@echo off

dir /b "C:\*BEG*"
pause

dir /? |more

exit /b

Re: Dos function for search files

Posted: 22 Nov 2011 01:22
by programchen
no, I 'm asking how to find files with *BEG*. the file can be in root directory C", it can be in subfolder C:\abcd\efg\

I want to know both the file name and directory.

dir /b "C:\*BEG*" only check root directory

pls help. thanks

Re: Dos function for search files

Posted: 22 Nov 2011 01:34
by renzlo
hi programchen,

Ed already showed you how to do it:

from dir /? command:
/S Displays files in specified directory and all subdirectories.


so it should be:
dir /s /b "C:\*BEG*"

-renzlo

Re: Dos function for search files

Posted: 22 Nov 2011 01:53
by programchen
thanks