help!
Moderator: DosItHelp
Re: help!
Code: Select all
@echo off
set "log=output.log"
set "search=MYWORD!"
set "startPath=."
::Dot implies current directory
(for /f "delims=" %%F in ('dir /s /b "%startPath%\*.txt"') do findstr /c:"%search%" "%%F" >nul && echo %%F)>"%log%"
Dave Benham
Re: help!
glob5 wrote:I AM NEW TO BAT SCRIPT WORLD. MY SCRIPT DOES NOT WANT TO WORK. MY BAT SCRIPT HAS TO start from a path and RECURSIVELY SEARCH ALL THE FILES OF TYPE .TXT THAT HAS THE WORD "MYWORD!" AND WRITE THEIR NAMES TO A LOG FILE.
This seems like trollish spam, but I will take it seriously.
Code: Select all
@echo off
dir /b /a /s | find "MYWORD!" > ~tmp.txt
type ~tmp.txt | find ".txt" > log.txt
type ~tmp.txt | find ".TXT" >> log.txt
del ~tmp.txt
That will search all directories and list files containing "MYWORD!" and will only list them if the extensions are ".txt" or ".TXT".
Re: help!
What about
Note that it's searching in a case-sensitive manner (that could be a problem because it seems your caps lock key is out of order). Otherwise you have to include the /i option (/imsc:).
Regards
aGerman
Code: Select all
>"my.log" findstr /msc:"MYWORD1 MYWORD2" "C:\wherever\*.txt"
Note that it's searching in a case-sensitive manner (that could be a problem because it seems your caps lock key is out of order). Otherwise you have to include the /i option (/imsc:).
Regards
aGerman