Share via


Search for text in sub-folders

Question

Monday, April 8, 2019 5:50 PM

How can I modify this code so that the command also runs in the subfolders?

Findstr  /s /i POPULAR *.* > results.txt

All replies (5)

Monday, April 8, 2019 5:56 PM

This is not a script or a PowerShell script.  You are posting I n the wrong forum.  The command is a system utility command

To learn how to run any system command just add "/?" to the comma nd,.

FINDSTR /?

Read all of the help.

\(ツ)_/


Monday, April 8, 2019 5:58 PM

You are already doing that. That's what the "/s" switch does.

C:\Windows\System32>findstr /?
Searches for strings in files.
FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
        [/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
        strings [[drive:][path]filename[ ...]]
  /B         Matches pattern if at the beginning of a line.
  /E         Matches pattern if at the end of a line.
  /L         Uses search strings literally.
  /R         Uses search strings as regular expressions.
  /S         Searches for matching files in the current directory and all
             subdirectories.
  /I         Specifies that the search is not to be case-sensitive.
  /X         Prints lines that match exactly.
  /V         Prints only lines that do not contain a match.
  /N         Prints the line number before each line that matches.
  /M         Prints only the filename if a file contains a match.
  /O         Prints character offset before each matching line.
  /P         Skip files with non-printable characters.
  /OFF[LINE] Do not skip files with offline attribute set.
  /A:attr    Specifies color attribute with two hex digits. See "color /?"
  /F:file    Reads file list from the specified file(/ stands for console).
  /C:string  Uses specified string as a literal search string.
  /G:file    Gets search strings from the specified file(/ stands for console).
  /D:dir     Search a semicolon delimited list of directories
  strings    Text to be searched for.
  [drive:][path]filename
             Specifies a file or files to search.

Tuesday, April 9, 2019 9:33 AM

Hi,

 

You may check the following official link:

 

FINDSTR

/en-us/windows-server/administration/windows-commands/findstr

 

To search every file in the current directory and all subdirectories that contained the word Windows, regardless of the letter case, type:

        findstr /s /i Windows *.*

 

Hope these can help you. If you have any questions, please feel free to contact us.

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Friday, April 12, 2019 9:28 AM

Hi,

Was your issue solved?

If yes, would you like to share your solution in order that other community members could find the helpful reply quickly.

If no, please reply and tell us the current situation in order to provide further help.

Best

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Wednesday, April 17, 2019 9:53 AM

Hi,

Since you have not responded for a long time, we will temporarily archive this post.

If the reply helped you, please remember to mark it as an answer.

If you have any questions, please do not hesitate to contact us.

Best

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected].