Command to search multiple file types.

Command to search multiple file types.

Asked on October 24, 2018 in Windows.
Add Comment

  • 6 Answer(s)

    The files which are given with the extensions in the current working directory and all the related sub directories:

    dir *.cpp *.h *.java /b/s
    Answered on October 24, 2018.
    Add Comment
    findstr /p /s /i .

    Use the above command to search for the given text in current directories and the related sub directories. /n will print the line numbers .

    Answered on October 24, 2018.
    Add Comment

    SuperUser contributor AppsDev has the answer for us:

    Open Windows Explorer and in the top right search box type *.extension. For example, to search for text files you should type *.txt.

    For multiple file types use Ext:.doc OR Ext:.txt OR Ext:.pdf. Hope this helps you.

    Special Note: As noted in additional comments in the discussion thread, make sure that the word “OR” is capitalized when doing a search for multiple file types.

    Answered on January 19, 2019.
    Add Comment

    Alvaro’s suggestion is good. Standard dir command won’t be able to perform your search as a simple one-liner. You can write a script with three lines:

    dir /s \\server_name_and_path\*.jpg  > \\path_to_output_file\Report.txt
    dir /s \\server_name_and_path\*.mp3  >> \\path_to_output_file\Report.txt
    dir /s \\server_name_and_path\*.avi  >> \\path_to_output_file\Report.txt
    Answered on January 19, 2019.
    Add Comment

    I am looking for files in a particular directory that have the following extensions: .txt, .csv, and .xml. The directory has many levels of sub-directories that I would like to search through for all three file types in one go.

    When I use Ctrl+F in Windows Explorer and enter extension types like *.txt;*.csv;*.xml, I watch the search bar fill up with green for a long time, but end up with no results. I know there are hundreds of these file types in the parent directory and sub-directories though.

    How can I do a search like this in Windows 8 that returns results?

    Answered on February 17, 2019.
    Add Comment

    First change your Dir command to look for folder & "\*.*. While you’ve neglected to incude that important postion of your code, a Dir list isn’t going to return anything that is outside of its file mask. Next, pull the file extension off the right hand end and compare it to a list of desired file extensions.

    dim folder as string, pfile as string, ext as string
    folder = "c:\temp"
    pfile = Dir(folder & "\*.*")
    do while cbool(len(pfile))
        ext = chr(32) & lcase(trim(right(replace(pfile, chr(46), space(99)), 99))) & chr(32)
        if cbool(instr(1, " pdf docx doc xls xlsx ", ext, vbTextCompare)) then
            'do something with the matching file
        end if
        pfile = Dir
    Answered on February 21, 2019.
    Add Comment

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.