findstr rather than
find to get the file name and line content of matches only. Or use it to get the file name only of any file(s) that contain any number of matches.
This solution doesn't require complex batch logic or putting the
find command in a loop to parse output and such to get the expected result(s).
findstr "str1" *.*
File.txt:"str1","same file","different line"
File2.txt:"some line","str1","different file"
File9.txt:"another line","different file","str1
File.ext:display whole line containing matching string
Note: This shows the file name each time for each line in any file that a matching string is found—and it also displays the line content which the matching string is found.
findstr /M "str1" *.*
Note: This shows the file name only and only once for each matching file containing any matching string within its content.
/I Case-insensitive search.
/S Search subfolders.