Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Help needed in Text file

14 Feb 2015   #1
born2achieve

windows7 64 bit
 
 
Help needed in Text file

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 System SpecsSystem Spec
.
15 Feb 2015   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

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
My System SpecsSystem Spec
15 Feb 2015   #3
born2achieve

windows7 64 bit
 
 

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 System SpecsSystem Spec
.

15 Feb 2015   #4
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Double up the percent symbols when running the commands in batch files. E.g. "%A" should become "%%A".
My System SpecsSystem Spec
15 Feb 2015   #5
born2achieve

windows7 64 bit
 
 

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 System SpecsSystem Spec
15 Feb 2015   #6
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Your script snippet's syntax is incorrect. Use one of the two lines I've suggested above.
My System SpecsSystem Spec
15 Feb 2015   #7
born2achieve

windows7 64 bit
 
 

Sorry my bad, you script is perfect. worked like charm.

thank you so much for your time on this
My System SpecsSystem Spec
15 Feb 2015   #8
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

Always welcome
My System SpecsSystem Spec
Reply

 Help needed in Text file




Thread Tools




Similar help and support threads
Thread Forum
Help needed in printing the text
Hello Friends, I am having bunch of url and trying to check whihc url has broken. Finlly endup with creating powershell command. below the code working fine. @echo off powershell -command "gc 'links.txt'|%%{if($(try{::Create($_).GetResponse().Statuscode}Catch{}) -eq 200){$_}}|sc...
General Discussion
How do I change JPEG to text file...add text and reconvert to JPEG?
I need to find out if I can change a JPEG to a txt file...insert random text and reconvert to JPEG in order to see how I can create a distorted/new image. Is it possible...and if so how?
Music, Pictures & Video
How to create .bat file to change the text in an .ini file?
I have the original Zoo Tycoon. It has no built in widescreen support, but it's possible to get it by changing some information in its .ini file. I don't want to leave it at that though, as I also have a 4:3 monitor, and I switch between the two. I don't want to have to go into the ini file and...
Gaming
Help Needed with Searching File/Folder/Move .Bat file
I've been searching the last 2 hours on a solution to my problem & have yet to find an answer so I thought I would post it here. Description of Problem: I have a folder dedicated for songs (guitar tabs & chords) that are .htm extensions, however I would like to move these songs to the/an...
Software
Windows file contents to text file
i need a list of everything on my hard drive i can access in a text file without manually pounding the folder/sub folder and contents names into notepad is there anyway this can be achieved?
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:09.
Twitter Facebook Google+