Help Needed in Text File

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
born2achieve
Posts: 51
Joined: 16 Nov 2014 20:28

Help Needed in Text File

#1 Post by born2achieve » 14 Feb 2015 22:30

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

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: Help Needed in Text File

#2 Post by Squashman » 14 Feb 2015 23:31

Findstr /m /s "Core" *.txt

born2achieve
Posts: 51
Joined: 16 Nov 2014 20:28

Re: Help Needed in Text File

#3 Post by born2achieve » 14 Feb 2015 23:43

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

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Help Needed in Text File

#4 Post by ShadowThief » 15 Feb 2015 00:29

If you get no output from that command, then there are no files that contain the word "Core"

ShadowThief
Expert
Posts: 1167
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Help Needed in Text File

#5 Post by ShadowThief » 15 Feb 2015 00:34

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Help Needed in Text File

#6 Post by foxidrive » 15 Feb 2015 04:02

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 ?

born2achieve
Posts: 51
Joined: 16 Nov 2014 20:28

Re: Help Needed in Text File

#7 Post by born2achieve » 15 Feb 2015 08:54

Hi Shadow, your solution worked perfectly. thank you.

thanks everyone who participated on this post.

Post Reply