user2254686
user2254686

Reputation: 95

cmd - Search folder for a string inside all files - return file name when found

Could anyone give me an example or solution for finding a string within a folder full of files.

When the string is found in one of the files - then the bat file should return the name of the file that contains it.

e.g.

Inside: "C:\MyDocuments\Files\" is:

samplefile1.xml

samplefile2.xml

samplefilen.xml...

samplefile1000.xml

Search for string: '000234'

if found, return the name of the file in which it was found.

Here's an idea of what I'm doing (wrong :) at the moment:

findstr /S /M "000234" "C:\MyDocuments\Files\"

pause

Upvotes: 1

Views: 1570

Answers (1)

Oscar
Oscar

Reputation: 13960

Change directory to C:\MyDocuments\Files\ and fire:

findstr /S /M /L /C:"000234" *.xml

Upvotes: 3

Related Questions