Page 2 of 2

Re: recursive search for string

Posted: 20 Apr 2012 08:39
by doscode
abc0502:
notepad++ can save the results?

Re: recursive search for string

Posted: 20 Apr 2012 10:04
by abc0502
no unfortunately but if u wan't fast search then u have to use a program designed for searching or other fast programming language.

Re: recursive search for string

Posted: 20 Apr 2012 10:21
by Squashman
doscode wrote:I just have rewrite what I had seen on dialog window of my local system. The size of whole structure has 14,9MB on disk. 15MB.

15 Megabytes worth of files shouldn't take 4 minutes to find a single file. Especially with the code Foxi is using. Something don't seem right with your setup.

What directory are you executing the script from?

Re: recursive search for string

Posted: 20 Apr 2012 14:48
by doscode
I execute the script from

P:\server\searchengine\

Re: recursive search for string

Posted: 20 Apr 2012 14:51
by doscode
abc0502:
Then I don't understand why you suggest Notepad++. I look(ed) for script to recover damaged files from backup.

Re: recursive search for string

Posted: 20 Apr 2012 20:12
by foxidrive
Did you run the script overnight?

Re: recursive search for string

Posted: 20 Apr 2012 21:24
by foxidrive
Try this: It will report each filename as it is tested.
When you said that it took 4 minutes to find one file, it might have tested 2000 files in that time.


Code: Select all

@echo off
for /f "delims=" %%a in ('dir *.txt /b /s') do (
echo "%%a"
for /f "delims=" %%b in ('find "</coordinates>" ^<"%%a" ^|find /c /v "" ') do (
if %%b GTR 1 >>"found.txt" echo %%a
)
)

Re: recursive search for string

Posted: 21 Apr 2012 03:05
by abc0502
Try This i tested on 984 text file it took few seconds, replace the variable section with ur's:
This search for all the file types u choose then log there location in log.log file and use this log.log file to search for the string u choose so it make the search faster
if it worked with u i can make it looks better

Code: Select all

@echo off
cls
:: === Variables ======================
set "log=%temp%\log.log"
set "found=%userprofile%\desktop\Resulte.txt"
set "loc=D:"
set "type=*.txt"
set "string=text"
:: === Code =========================
if exist %log% Del /F /Q %log%
for /f "tokens=*" %%c in ('dir /b /s /a-d "%loc%\%type%"') do (
echo %%c >>"%log%"
)
For /f "tokens=*" %%g in (' findstr /m /F:%log% "%string%"') do echo %%g >>%found%

But it has one problem i can't make it check if the string exist more than once so if the string found at least once it put the file directory and name in the resulte file
try it and let me know ur results :)