Solved Help needed in Text file

born2achieve

New member
Local time
3:57 PM
Messages
36
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:
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
 

My Computer

Computer type
PC/Desktop
OS
windows7 64 bit
Hello Born2achieve (remember me? :)),

Do these command line snippets help you achieve your goal?

Code:
for %A in ( C:\Sample\*.txt ) do find "Core" "%~A" && echo %~fA>> output.txt


Below is the same but recurses the search into sub-folders, starting at C:\Sample,

Code:
for /r "C:\Sample" %A in ( *.txt ) do find "Core" "%~A" && echo %~fA>> output.txt
 
Last edited:

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Hi Phyroply,

Thakns for your reply and sorry it's not working for me. Below is the output,

Code:
C:\Sample>search.bat
The following usage of the path operator in batch-parameter
substitution is invalid: %~A" && echo %~fA>> output.txt

For valid formats type CALL /? or FOR /?
search.bat was unexpected at this time.

Any suggestions or corrections
 

My Computer

Computer type
PC/Desktop
OS
windows7 64 bit
Double up the percent symbols when running the commands in batch files. E.g. "%A" should become "%%A".
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
sorry, still it doesn't finds the keyword.

This is my code

Code:
for /R %%A in (C:\Sample\*.txt) do find "core" "%%~A" && echo %%~fA>> output.txt

any suggestion please
 

My Computer

Computer type
PC/Desktop
OS
windows7 64 bit
Your script snippet's syntax is incorrect. Use one of the two lines I've suggested above.
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Sorry my bad, you script is perfect. worked like charm.

thank you so much for your time on this
 

My Computer

Computer type
PC/Desktop
OS
windows7 64 bit
Always welcome ;)
 

My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Back
Top