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 Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
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
Adding text to a .pdf file
I have an official document that I have scanned in to a .pdf file, and I want to add some text that says 'I certify that this is a true copy of this document' (I do not want to change the document itself, and this will save me having to write this text on 20 pages). Is there a simple (and cheap)...
General Discussion
Missing New text file
Hi I didn't know which section would be best for this tread so i'm posting it there... So my problem is that few days ago the option of creating new text file through rightclick of mouse has dissapeared. concretly rightclick(context)->new-> textfile and this option is missing. please can...
General Discussion
green text name of file
please tell me..more about.. I have many file ...so i dont know..why th name of these file is green color.? in the last...i was denied those file..and then i allow them again... so.. pleas me solution for known my problem.. :confused::cry:
BSOD Help and Support
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 21:50.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App