Reputation: 69
Hello I'm very new to dos, but I need a batch file that searches through all files in a directory for a certain string and copy those lines to a new file.
FOR /R %%G IN (*) DO FIND "string" C:\ "%%G" > result.txt
But I can't get it to work
Upvotes: 1
Views: 220
Reputation: 57252
this worked for me through the command prompt:
for /r %G in (*) do @find "import" "%~G" >nul 2>&1 && @echo %G
EDIT: To see lines and numbers:
for /r %G in (*) do @findstr /n "issue" "%~G" 2>null && @echo %G
Upvotes: 2