DOS - Search Command

Zertux -  
bricomachin Posted messages 245 Registration date   Status Member Last intervention   -
Hello,

Is there a command that allows searching through all .txt files in a folder for a word? And that gives the name of the file afterwards?

Example:

I have 30 .txt files in my folder MyTextFiles. I want to search for the word "Hello" in all .txt files in MyTextFiles.

Then, DOS tells me which .txt file(s) contain "Hello".

Is that possible? Thank you!

Configuration: Windows XP / Firefox 3.6.8

1 answer

  1. bricomachin Posted messages 245 Registration date   Status Member Last intervention   134
     
    C:\Documents and Settings\Administrateur>findstr /?
    Search for strings in files.

    FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P]
    /F:file /C:string /G:directory file
    color [strings]
    [[drive:][path]filename[ ...]]

    /B Searches for the element if it is at the beginning of a line.
    /E Searches for the element if it is at the end of a line.
    /L Searches for the strings literally.
    /R Searches for strings as expressions.
    /S Searches for matching files in the current directory
    and all its subdirectories.
    /I Specifies that the search should be case-insensitive.
    /X Displays lines that match exactly.
    /V Displays only non-matching lines.
    /N Displays the line number before each matching line.
    /M Displays only the names of files containing
    matching strings.
    /O Displays the character offset for each matching line.
    /P Ignores files that do not contain printable characters.
    /OFFLINE Do not ignore files with the offline attribute set.
    /A:attr Specifies the color attribute with 2 hexadecimal digits.
    Enter "color /?".
    /F:file Reads the list of files from the specified file (/ for the
    console).
    /C:string Searches for the specified string literally.
    /G:file Gets the strings to search for from the specified file
    (/ for the console).
    /D:dir Searches in a list of directories delimited by
    semicolons.
    strings Strings to search for.
    [drive:][path]filename
    Specifies the files in which to search.

    Use spaces to separate multiple strings to search for, unless
    the argument is preceded by /C.
    Example: 'FINDSTR "have a good day" x.y' searches for "have" or "day" in
    the file x.y. 'FINDSTR /C:"have a good day" x.y' searches for "have a good day"
    in the file x.y.

    Quick guide to common options:
    . Wildcard = any character
    * Repetition: zero occurrences or more of the preceding character or class
    ^ Position: beginning of line
    $ Position: end of line
    [class] Character class: any character from the set
    [^class] Inverted class: any character not belonging to the set
    [x-y] Limits: any character within the specified limits
    \x Escaping: literal use of the metacharacter x
    \<xyz Position: beginning of the word
    xyz\> Position: end of the word

    found in the command prompt
    1