How to search file name using dos in windows

Posted on 2007-10-09
Last Modified: 2008-01-09
How do you find files in dos in windows, basically I want to create a batch file which finds files with specific name and creates an another text file with all of those files. For example, if I have 100 files in C:\test and only 5 files contains abcd or pqrs in the filename, it should print only those files and nothing else.

Prompt response will be highly appreciated.


Question by:ashutoshg2006
    LVL 7

    Expert Comment

    dir *abcd*.*
    dir *pqrs*.*

    ...unfortunately dir is only able to look for one thing at a time (that is, if you want to find something you need "OR-logic", you need to find them in separate runs.
    LVL 27

    Expert Comment

    LVL 9

    Accepted Solution

    you can try dir /S | findstr "your search string"
    LVL 7

    Expert Comment

    @ghostdog74: Much better than my approach. Must admit that that ("findstr") was entirely new command for me (though it must be said that I hardly ever use Windows' command line any more). Too bad that /S doesn't keep the directory name with the filename - otherwise that'd be really usefull...

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now