how to search for file contents

Microsoft Running ms-dos 20th anniversar...
February 19, 2010 at 03:33:41
Specs: Windows XP
i want all the list of file names which are having a perticular string "TEST_INIT_VALUES" in a perticular directory

How to get that list of file names which have "TEST_INIT_VALUES" string in them
Note: Files are in XML format

I want list of file names which have that string, I need output in a txt file


See More: how to search for file contents

Report •

#1
February 19, 2010 at 05:30:25
Using DOS or XP?


=====================================
Helping others achieve escape felicity

M2


Report •

#2
February 19, 2010 at 05:50:26
its DOS not XP



Report •

#3
February 19, 2010 at 19:26:42
I always used a text search program in dos norton utilities for that. It's a stand alone file called ts.exe. There's also the FIND command:

http://www.computerhope.com/findhlp...

You're not really green until you're soylent green.


Report •

Related Solutions

#4
February 21, 2010 at 21:01:42
Its not working, actually i am using below command

dir /s *.xml | find "TEST_INIT_VALUES" > log.txt

this command is not working, it is not listing the filenames which are having string "TEST_INIT_VALUES" in log.txt

can u tell me correct command to use for listing files which are having string "TEST_INIT_VALUES" in log.txt


Report •

#5
February 21, 2010 at 23:51:23
The DIR only shows the file names and as such that is all that is piped to the FIND command. That is, FIND will return a file name if part of the file name is "TEST_INIT_VALUES" but will not return that file name if "TEST_INIT_VALUES" is within the file itself.

And unfortunately wild cards don't work for the FIND command (in spite of what it says in the link in my # 3) so you can't use FIND C:\*.XML "TEST_INIT_VALUES" > LOG.TXT. Besides I don't think there are any switches for the find command to search subdirectories.

Offhand I can't think of a way to use the FIND command for your purposes but Mechanix2Go may post back with more info.

You may be able to use the norton utilities TS.EXE I mentioned. The version I have is from old dos days (fat16, 8.3 format file names) so I don't know if it'll work on fat32 partitions and I'm sure it won't work in NT command prompt. There might be more recent versions that will work.

And no doubt there are other text search programs but I wouldn't have any recommendations on those.

You're not really green until you're soylent green.


Report •

#6
February 21, 2010 at 23:58:50
NO i dont have TS.exe to make use & moreover i want DOS command for this. I want keep that command in a batch file to use repeatedly.

so can u give me answer for the same in dos if it is available

Thank u


Report •

#7
February 22, 2010 at 00:39:20
I don't know how to do it with just ms dos commands or even if it's possible. But likely someone has written a program that will run in dos and do what you want. I can send you TS.EXE (which is a dos program) but otherwise can't do anything else for you.

You're not really green until you're soylent green.


Report •

#8
February 22, 2010 at 01:02:17
can u send me that TS.exe, will check once with that

please give me info how to use that tool also


Report •

#9
February 22, 2010 at 01:56:59
Hi DAVEINCAPS,

I don't know any way aroud it.

----------------------------
You're not really DAVEINCAPS 'til you're soylent DAVEINCAPS

:(


=====================================
Helping others achieve escape felicity

M2


Report •

#10
February 22, 2010 at 12:04:53
"Mmm, good cracker"

nmp1kor, post back your email or send it in a private message.

You're not really green until you're soylent green.


Report •

#11
February 22, 2010 at 16:55:34
this is klunky but it might work:
SET XML=\XMLDIRS
CD %XML%
DEL EDL.IN
ECHO 1,#RC:\ TESTOUT FIND /I /C "TEST_INIT_VALUES" C:\>> EDL.IN
ECHO E>> EDL.IN
DEL DEB
>> DEB ECHO E107 1A 3E 3E
>> DEB ECHO W
>> DEB ECHO Q
DEBUG EDL.IN < DEB
DIR /S /B *.XML > TEST1.BAT
EDLIN TEST1.BAT < EDL.IN
DEL TESTOUT
CALL TEST1.BAT
FIND /I /V ".XML: 0"<TESTOUT | FIND " " > EDL.IN
MOVE /Y EDL.IN TESTOUT
ECHO RESULTS ARE IN FILE TESTOUT.
:XIT

Report •

#12
February 22, 2010 at 21:24:47
No this is not working, it is just creating files, output is not coming,

by the by where i have 2 give path in above script for searching the files for string


Report •

#13
February 22, 2010 at 21:27:06
Hi DAVEINCAPS

my email ID is matrymanju1 @ gmail.com

please send to this

thank u

be careful with email dd - moderator


Report •

#14
February 22, 2010 at 21:46:10
I tried sending it but gmail seems to reject all attachments. Maybe you can change the settings on your end or post back a non-gmail address.

You're not really green until you're soylent green.


Report •

#15
February 22, 2010 at 22:10:01
did you catch the typo? be sure to fix "valuse" to "values"!
I'm sorry, forgot to put this at top (where "XMLDIR" is your
particular directory where xml files are):
CD \XMLDIR
DIR /S /B *.XML> TESTOUT
DEL EDL.IN
ECHO 1,#RC:\ TESTOUT FIND /I /C "TEST_INIT_VALUES" C:\>> EDL.IN


i repaired the whole thing in my original post as well. sorry bout that!


Report •

#16
February 22, 2010 at 23:12:21
DAVE,

Maybe try http://www.sendthisfile.com


=====================================
Helping others achieve escape felicity

M2


Report •

#17
February 22, 2010 at 23:44:30
Thanks, that works pretty good.

Nmp1kor, I sent it again using Mechanix2Go's link. I guess they send you an email with a link. Click the 'edit' button in your # 13 and delete your email address.

You're not really green until you're soylent green.


Report •

#18
February 23, 2010 at 00:09:14
Hello nbrane

with respect to ur script in response #15 is not working.
output is not coming in TESTOUT

One more input, script is opening all the xml files which are present in search path & is not forwarding if u dont close the file

can u modify the script, so that it will not open the file & it should generate the list to make seaching faster & friendly

Thank u


Report •

#19
February 23, 2010 at 00:39:31
Hello Nbrane,

I had modified ur script like below

C:
CD \input
DIR /S /B *.XML> c:\TESTOUT.txt
DEL c:\EDL.txt
ECHO 1,#R c:\TESTOUT.txt FIND /I /C "TEST_INIT_VALUES" >> c:\EDL.txt
ECHO E>> c:\EDL.txt
DEL c:\DEB
>> c:\DEB ECHO E107 1A 3E 3E
>> c:\DEB ECHO W
>> c:\DEB ECHO Q
DEBUG c:\EDL.txt < c:\DEB
DIR /S /B *.XML > c:\TEST1.BAT
EDLIN c:\TEST1.BAT < c:\EDL.txt
DEL c:\TESTOUT
FIND /I /V ".XML: 0"< c:\TESTOUT | FIND " " > c:\EDL.txt
MOVE /Y c:\EDL.txt c:\TESTOUT
ECHO RESULTS ARE IN FILE TESTOUT.
:EXIT

But this is listing only XML files which are availables in the directory & it is not listing files which are having string TEST_INIT_VALUES

can u pls correct the script


Report •

#20
February 23, 2010 at 01:10:42
Hi Nbrane

I tried a lot with below script, its not working

it is listing only XML files which are availables in the directory & it is not listing files which are having string TEST_INIT_VALUES

I think there is a problem with TEST OUT, we are using that one before initialising in the line

ECHO 1,#R c:\TESTOUT FIND /I /C "TEST_INIT_VALUES"

Check below script, correct & send me pls

C:
CD \input
DEL c:\EDL.txt
ECHO 1,#Rc:\TESTOUT.txt FIND /I /C "TEST_INIT_VALUES" >> c:\EDL.txt
ECHO E>> c:\EDL.txt
DEL c:\DEB.txt
>> c:\DEB.txt ECHO E107 1A 3E 3E
>> c:\DEB.txt ECHO W
>> c:\DEB.txt ECHO Q
DEBUG c:\EDL.txt < c:\DEB.txt
DIR /S /B *pavast.XML > c:\TEST1.BAT
EDLIN c:\TEST1.BAT < c:\EDL.txt
DEL c:\TESTOUT.txt
FIND /I /V ".XML: 0"< c:\TESTOUT.txt | FIND " " > c:\EDL.txt
MOVE /Y c:\EDL.txt c:\TESTOUT.txt
ECHO RESULTS ARE IN FILE TESTOUT.
:EXIT


Report •

#21
February 23, 2010 at 01:22:49
Try this:

===============================

@echo off > found

for %%a in (*.*) do find "string" < %%a > nul & if not errorlevel 1 echo %%a >> found


=====================================
Helping others achieve escape felicity

M2


Report •

#22
February 23, 2010 at 01:35:49
an error was thrown like below

%%a was unexpected at this time

what is " %%a" here ?


Report •

#23
February 23, 2010 at 01:45:14
Mechanix2Go, u r awesome, its working

thank u for ur info


Report •

#24
February 23, 2010 at 02:11:55
Hello Mechanix2Go,

One problem, the above command is working only for the xml which are present in the same directory & it is not searching recursively in all directories which are present in the main directory, i changed ur command to below form but it is not working.

can u pls change ur command to search recursively in all directories present in the main directory

@echo off > "C:\Found.txt"
dir/s/b *pavast.xml > "C:\log.txt"
for %%a in ("C:\log.txt") do find "TEST_INIT_VALUES" < %%a > nul & if not errorlevel 1 echo %%a >> "C:\Found.txt"


Report •

#25
February 23, 2010 at 02:33:45
do VER and post result.


=====================================
Helping others achieve escape felicity

M2


Report •

#26
February 23, 2010 at 09:46:23
Lol! yeah, you definitely kicked my ass on this one!
i keep forgetting that errorlevel works in dos, just not able to be captured to a variable. also didn't know you can use & to stack commands onto an IF (in dos) like you can in XP.

Report •

#27
February 24, 2010 at 00:56:24
Hello Mechanix2Go,

Can u pls explain how the below command will work if possible

===============================

@echo off > found

for %%a in (*.*) do find "string" < %%a > nul & if not errorlevel 1 echo %%a >> found


=====================================

I am not understanding that errorlevel concept

Thank you


Report •

#28
February 24, 2010 at 01:26:55
Like I said in #25 do a VER and post output.


=====================================
Helping others achieve escape felicity

M2


Report •

#29
February 24, 2010 at 01:31:53
My Version is Microsoft Windows XP [Version 5.1.2600]

The command is working for me, it satisfied my job

i want to know abt that command

what that error level is doing there


Report •

#30
February 24, 2010 at 05:06:14
Just think, if we'd known sooner that it isn't DOS we could have saved some lost motion and helpers' patience.


=====================================
Helping others achieve escape felicity

M2


Report •

#31
February 24, 2010 at 05:18:46
Explain command how it is working if possible

Report •

Ask Question