Page 1 of 1
Help Needed in Text File
Posted: 14 Feb 2015 22:30
by born2achieve
Hi, I have a folder which has 20 text files and i need to find a word "Core" on the text files and and need to list out the file name where the text "Core" exists.
Code: Select all
for /R %%a in (C:\Sample\*.txt) do find "%Core" %%a >> output.txt
But the above code is not working as expected. any sample code to achieve this please
Re: Help Needed in Text File
Posted: 14 Feb 2015 23:31
by Squashman
Findstr /m /s "Core" *.txt
Re: Help Needed in Text File
Posted: 14 Feb 2015 23:43
by born2achieve
Hi Squashman,
I did copy your code and created .bat file and executed. id didn't do anything. no reaction. actually i supposed ot get a output file with file names where the keyword exists.
Any help plesse
Re: Help Needed in Text File
Posted: 15 Feb 2015 00:29
by ShadowThief
If you get no output from that command, then there are no files that contain the word "Core"
Re: Help Needed in Text File
Posted: 15 Feb 2015 00:34
by ShadowThief
However, if you think there might be instances of "core", "CORE", "CoRe", or some other weird casing going on in the files, you can try
Code: Select all
findstr /m /s /i "core" C:\Sample\*.txt>>output.txt
Re: Help Needed in Text File
Posted: 15 Feb 2015 04:02
by foxidrive
born2achieve wrote:Hi Squashman,
I did copy your code and created .bat file and executed. id didn't do anything. no reaction.
Did you call your batch file
findstr.bat ?
Re: Help Needed in Text File
Posted: 15 Feb 2015 08:54
by born2achieve
Hi Shadow, your solution worked perfectly. thank you.
thanks everyone who participated on this post.