Posts: 858
Threads: 196
Joined: Apr 2005
Is possible modify or add a function to do this?
Posts: 12,061
Threads: 140
Joined: Dec 2002
Use standard enumerating. Get file data. To find text, call find() or other string function...
Posts: 858
Threads: 196
Joined: Apr 2005
Thanks.
Is it the same algorithm that windows uses?
Posts: 12,061
Threads: 140
Joined: Dec 2002
Windows may use text indexing. QM calls API function FindFirstFile etc.
Posts: 858
Threads: 196
Joined: Apr 2005
Windows can search text in xls files and is faster, "Get file data" no...
Posts: 858
Threads: 196
Joined: Apr 2005
findstr.exe do it. Is possible implement in QM?
Posts: 12,061
Threads: 140
Joined: Dec 2002
Maybe. I have some old code that manipulates Windows Indexing Service through COM interfaces. Will post later.
Posts: 12,061
Threads: 140
Joined: Dec 2002
It probably was for WinXP. Does not work now on Win7.
Posts: 858
Threads: 196
Joined: Apr 2005
Quote:The findstr.exe command is an external command that is available in the below Microsoft operating systems.
Windows 2000
Windows ME
Windows XP
Windows Vista
Windows 7
do you know how it works?
Posts: 12,061
Threads: 140
Joined: Dec 2002
Posts: 12,061
Threads: 140
Joined: Dec 2002
Macro
Windows Search SQL sample
;Shows how to use Windows Search (WS) from QM, using SQL query.
;WS is a Windows component that is used to find files.
;For example, Windows uses it when you type in the search boxes in Start menu and Windows Explorer. You can access and change WS settings from there.
;It is in Vista/7. For XP can be downloaded from Microsoft.
;WS documentation: http://msdn.microsoft.com/en-us/library/ff628790%28v=VS.85%29.aspx
;WS SQL reference: http://msdn.microsoft.com/en-us/library/bb231256%28v=VS.85%29.aspx
;Shell properties (System.XXX) reference: http://msdn.microsoft.com/en-us/library/dd561977%28VS.85%29.aspx
;This code is converted from the 'WSFromScript' VBScript sample.
;Also there are other ways to use WS.
out
IDispatch objConnection objRecordSet
objConnection._create("ADODB.Connection")
objRecordSet._create("ADODB.Recordset")
;This is the Windows Search connection string to use
objConnection.Open("Provider=Search.CollatorDSO;Extended Properties='Application=Windows';")
;SQL SELECT statement specifies what properties to return, you can add more if you want
;;;;;FROM - use SystemIndex for a local query or MACHINENAME.SystemIndex for remote
;;;;;WHERE - specify restrictions including SCOPE and other conditions that must be true
;This is a very simple query over the whole index. To add scope restriction append "WHERE SCOPE='file:c:/users'" to the query string.
objRecordSet.Open("SELECT TOP 10 System.ItemPathDisplay, System.ItemTypeText, System.Size FROM SystemIndex" objConnection) ;;display the first 10 indexed files; remove the 'TOP 10' to display all.
;objRecordSet.Open("SELECT System.ItemPathDisplay, System.ItemTypeText, System.Size FROM SystemIndex WHERE SCOPE='file:d:\downloads'" objConnection) ;;search single folder and its subfolders; to skip subfolders, use DIRECTORY instead of SCOPE.
;objRecordSet.Open("SELECT System.ItemPathDisplay, System.ItemTypeText, System.Size FROM SystemIndex WHERE CONTAINS('macro')" objConnection) ;;search all containing word "macro"
;objRecordSet.Open("SELECT System.ItemPathDisplay, System.ItemTypeText, System.Size FROM SystemIndex WHERE CONTAINS(System.Author,'G')" objConnection) ;;search all where author is "G"
objRecordSet.MoveFirst
rep
,if(objRecordSet.EOF) break
,;Access the column values that were specified in the SELECT statement here
,str s1 s2; int i
,s1=objRecordSet.Fields.Item("System.ItemPathDisplay")
,s2=objRecordSet.Fields.Item("System.ItemTypeText")
,i=objRecordSet.Fields.Item("System.Size"); err i=0
,out "'%s' '%s' '%i'" s1 s2 i
,objRecordSet.MoveNext
Posts: 858
Threads: 196
Joined: Apr 2005
Thanks, but what I'm looking for is to search within any file without indexing previously.
Posts: 12,061
Threads: 140
Joined: Dec 2002
I don't know other functions that would search in files of any format.
Posts: 858
Threads: 196
Joined: Apr 2005
I was hoping there was some API or function to do it
Function
findstr_files
function~ ~substring ~path
str fin
_s.format("findstr.exe /mis ''%s'' ''%s''" substring path)
RunConsole2(_s fin)
ret fin