0
Thanks

A few words of thanks would be greatly appreciated.

MS-DOS – Searching a file




Issue


I want to write a batch file that allows me to search a name in CMD for example if I write this command in CMD search c:new folder s
every files that has s in the name of it should be listed like see saw or anything else.

Solution


If just you want to run the command as a batch, you can simply type the same into the batch program and run it.

In case you want to hard code the dir
dir /a-d "c:new folder*s*" 


In case you want to supply it as a parameter. In this case enclose the c:new folder*s* in the ". Say batch file is test.bat, then run it as test "c:new folder*s*"
dir /a-d %1 



If you are trying to capture the result, you may want to pipe it to some file, like
dir /a-d "C:new folder*s*" > mysearch.txt

Note


Thanks to rizvisa1 for this tip on the forum.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.
This document, titled "MS-DOS – Searching a file," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments