Jump to content
Sign in to follow this  
CyberFunk Productions

search program

Recommended Posts

a long time ago in the beggining stages of v3 someone made a program with auto-it that can search through any dir(like c:\) and find a file name with a certain extention. I think it was more then a year ago, maby 2. I don't remember the users name but he had a picture of mr.clean as an avatar. If anyone remembers this or knows of a similar program please let me know.

Share this post


Link to post
Share on other sites

was it this one??? (by larry)

include <GUIConstants.au3>

#include <File.au3>

#include <Array.au3>

#include <String.au3

; _FileSearch( <Path and Mask>, <Option (0 - normal, 1- recursive)>)

; Returns array. Either Array of files (full path) where...

; Array[0] is number of files.

; Array[0] = 0 if nothing found.

;

; EXAMPLE USAGE

;--------------------------------------------

$a = _FileSearch(@HomeDrive & "\*.dat",1)

If $a[0] > 0 Then

For $i = 1 to $a[0]

MsgBox(4096,"Great!",$a[$i])

Next

EndIf

;--------------------------------------------

Func _FileSearch($szMask,$nOption)

$szRoot = ""

$hFile = 0

$szBuffer = ""

$szReturn = ""

$szPathList = "*"

Dim $aNULL[1]

If Not StringInStr($szMask,"\") Then

$szRoot = @SCRIPTDIR & "\"

Else

While StringInStr($szMask,"\")

$szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\"))

$szMask = StringTrimLeft($szMask,StringInStr($szMask,"\"))

Wend

EndIf

If $nOption = 0 Then

_FileSearchUtil($szRoot, $szMask, $szReturn)

Else

While 1

$hFile = FileFindFirstFile($szRoot & "*.*")

If $hFile >= 0 Then

$szBuffer = FileFindNextFile($hFile)

While Not @ERROR

If $szBuffer <> "." And $szBuffer <> ".." And _

StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _

$szPathList = $szPathList & $szRoot & $szBuffer & "*"

$szBuffer = FileFindNextFile($hFile)

Wend

FileClose($hFile)

EndIf

_FileSearchUtil($szRoot, $szMask, $szReturn)

If $szPathList == "*" Then ExitLoop

$szPathList = StringTrimLeft($szPathList,1)

$szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\"

$szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1)

Wend

EndIf

If $szReturn = "" Then

$aNULL[0] = 0

Return $aNULL

Else

Return StringSplit(StringTrimRight($szReturn,1),"*")

EndIf

EndFunc

Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN)

$hFile = FileFindFirstFile($ROOT & $MASK)

If $hFile >= 0 Then

$szBuffer = FileFindNextFile($hFile)

While Not @ERROR

If $szBuffer <> "." And $szBuffer <> ".." Then _

$RETURN = $RETURN & $ROOT & $szBuffer & "*"

$szBuffer = FileFindNextFile($hFile)

Wend

FileClose($hFile)

EndIf

EndFunc

????


NEWHeader1.png

Share this post


Link to post
Share on other sites

nope???? .... maybe thisone (also by larry)

#include <GUIConstants.au3>

#include <File.au3>

#include <Array.au3>

#include <String.au3>

#include <INet.au3>

;#Include <FileSearch.au3>

Dim $iMsgBoxAnswer

Dim $LookFor

$box=GUICreate("Hold *CONTROL KEY* to Select Muiltiple Files") ; will create a dialog box that when displayed is centered

$add=GUICtrlCreateButton ("Add", 164,360,75,25)

$clear=GUICtrlCreateButton ("Clear", 64,360,75,25)

$close=GUICtrlCreateButton ("Close", 264,360,75,25)

$mylist=GUICtrlCreateListView ("Num#| File Name | Location ",15,15,370,300)

GUICtrlSetLimit(-1,200) ; to limit horizontal scrolling

;GUICtrlSetData(-1,$MESSAGE)

GUISetState(@SW_SHOW,$mylist)

$iMsgBoxAnswer = MsgBox(48,"Searching","This may take a moment... Please wait...",3)

; Shows the filenames of all files in the current directory

$LookFor = "*.bak"

Dim $Files

Dim $Dir="C:\" ; specify the directory to search

Dim $Filemask=$LookFor ; specify the filemask

; Options are :

; 1 - looking in subfolders and not in current only

; 2 - show search status window

; 4 - cancel search by first match found

$Files = _FileSearch($Dir, $Filemask, 1+2) ; set can be 1+2+4

If $Files[0] > 0 Then

For $i = 1 to $Files[0]

;MsgBox(4096,"",$Files[$i])

GUISetState(@SW_SHOW,$mylist)

GuiCtrlCreateListViewItem($Files[$i],$mylist)

$count=ControlListView("Hold *CONTROL KEY* to Select Muiltiple Files","","SysListView321", "GetItemCount")

$selected=ControlListView("Hold *CONTROL KEY* to Select Muiltiple Files","","SysListView321", "GetSelectedCount")

GUICtrlCreateLabel("Found:" & $count,64,325,75,25)

GUICtrlCreateLabel("Selected:" & $selected,264,325,75,25)

GUISetState(@SW_SHOWMINNOACTIVE,$mylist)

Next

EndIf

Func _FileSearch($StartDir, $FileToFind, $Options)

; $StartDir = specify the directory to search

; $FileToFind = specify the filemask

; $Options = 1 - looking in subfolders and not in current only

; 2 - show search status window

; 4 - cancel search by first match found

Local $StartDir

Local $FileToFind

Local $Options

Local $FileIndex

Local $CurrDir

Local $sCriteria

Local $sBuffer

Local $iH, $iH2

Local $sCS, $sCF, $sCF2, $sCP, $sFP

Local $sOutPut = ''

Local $aNull[1]

; An array is returned with the full path of all files found. The pos [0] keeps the number of elements.

$sCP = StringLeft($StartDir, StringInStr($StartDir, '\', 0, -1))

If $sCP = '' Then $sCP = @WorkingDir & '\'

$sCriteria = StringTrimLeft($FileToFind, StringInStr($FileToFind, '\', 0, -1))

If $sCriteria = '' Then $sCriteria = '*.*'

; To begin we seek in the starting path

$sCS = FileFindFirstFile($sCP & $sCriteria)

If BitAND($Options,2) = 2 then

GUISetState(@SW_SHOWMINNOACTIVE,$mylist)

$box2=SplashTextOn("Indexing ... Please wait ...", $sCP, 400, 130, -1, -1, 22, "Arial", 10)

EndIf

While $sCS <> - 1

$sCF = FileFindNextFile($sCS)

If @error Then

FileClose($sCS)

ExitLoop

EndIf

If $sCF = '.' Or $sCF = '..' Then ContinueLoop

$info=$sCF

$sOutPut = $sOutPut & $sCP & $sCF & @LF

$FileIndex = $FileIndex + 1

GUISetState(@SW_SHOW,$mylist)

$count=ControlListView("Hold *CONTROL KEY* to Select Muiltiple Files","","SysListView321", "GetItemCount")

$selected=ControlListView("Hold *CONTROL KEY* to Select Muiltiple Files","","SysListView321", "GetSelectedCount")

GuiCtrlCreateListViewItem($FileIndex & "|" & $info & "|" & $currDir,$mylist)

GUICtrlCreateLabel("Found:" & $count,64,320,75,25)

GUICtrlCreateLabel("Selected:" & $selected,264,320,75,25)

GUISetState(@SW_SHOWMINNOACTIVE,$mylist)

If $FileIndex > 0 AND BitAND($Options,4) = 4 Then

FileClose($sCS)

ExitLoop

EndIf

Wend

; and after, if needed, in the rest of the folders.

If $FileIndex > 0 AND BitAND($Options,4) = 4 Then

Else

If BitAND($Options,1) = 1 Then

$sBuffer = @CR & $sCP & '*' & @LF; The buffer is set for keeping the given path plus a *.

Do

$sCS = StringTrimLeft(StringLeft($sBuffer, StringInStr($sBuffer, @LF, 0, 1) - 1),1); current search.

$sCP = StringLeft($sCS, StringInStr($sCS, '\', 0, -1)) ; current search path.

$iH = FileFindFirstFile($sCS)

If BitAND($Options,2) = 2 then

If StringLen($sCP) > 55 Then

$CurrDir = StringLeft($sCP, 10) & " ... " & StringRight($sCP, 40)

Else

$CurrDir = $sCP

EndIf

ControlSetText("Indexing ... Please wait ...", _

"", _

"Static1", _

@CRLF & " Searching Files and Folders :" & _

@CRLF & $CurrDir & _

@CRLF & @CRLF & _

@CRLF & " Search Name" & @TAB & $sCriteria & _

@CRLF & " Matching Files Found" & @TAB & $FileIndex)

EndIf

While $iH <> - 1

$sCF = FileFindNextFile($iH)

If @error Then

FileClose($iH)

ExitLoop

EndIf

If $sCF = '.' Or $sCF = '..' Then ContinueLoop

If StringInStr(FileGetAttrib($sCP & $sCF), 'd') Then

$sBuffer = @CR & $sCP & $sCF & '\*' & @LF & $sBuffer; Every folder found is added in the begin of buffer

$sFP = $sCP & $sCF & '\' ; for future searches

$iH2 = FileFindFirstFile($sFP & $sCriteria) ; and checked with the criteria.

While $iH2 <> - 1

$sCF2 = FileFindNextFile($iH2)

If @error Then

FileClose($iH2)

ExitLoop

EndIf

If $sCF2 = '.' Or $sCF2 = '..' Then ContinueLoop

$info=$scF2

$sOutPut = $sOutPut & $sFP & $sCF2 & @LF ; Found items are put in the Output.

$FileIndex = $FileIndex + 1

GUISetState(@SW_SHOW,$mylist)

$count=ControlListView("Hold *CONTROL KEY* to Select Muiltiple Files","","SysListView321", "GetItemCount")

$selected=ControlListView("Hold *CONTROL KEY* to Select Muiltiple Files","","SysListView321", "GetSelectedCount")

GuiCtrlCreateListViewItem($FileIndex & "|" & $info & "|" & $currDir,$mylist)

GUICtrlCreateLabel("Found:" & $FileIndex,64,320,75,25)

GUICtrlCreateLabel("Selected:" & $selected,264,320,75,25)

GUISetState(@SW_SHOWMINNOACTIVE,$mylist)

If $FileIndex > 0 AND BitAND($Options,4) = 4 Then ExitLoop

Wend

EndIf

Wend

$sBuffer = StringReplace($sBuffer, @CR & $sCS & @LF, '')

Until $sBuffer = '' Or $FileIndex > 0 AND BitAND($Options,4) = 4

EndIf

EndIf

If BitAND($Options,2) = 2 then

SplashOff()

EndIf

If $sOutPut = '' Then

$aNull[0] = 0

Return $aNull

Else

Return StringSplit(StringTrimRight($sOutPut, 1), @LF)

EndIf

GUISetState(@SW_SHOW,$mylist)

EndFunc ; ==>_FileSearch

?????????

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...