HAMID Posted September 8, 2011 Share Posted September 8, 2011 expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.6.1 Author: HAMID Script Function : MiniFinder 0 = Find Files/Folders 1 = Find Files 2 = Find Folders #ce ---------------------------------------------------------------------------- ; #FUNCTION# ==================================================================================================================== ; Name...........: MiniFinder ; Description ...: Find Files and folder ; Syntax.........: MiniFinder($RootAddress,$FindDepth=-1,$TextToFind="",$FindType=0,$TargetFileTypes=-1,$TextInFileContent="") ; Parameters ....: $RootAddress - root address fo find work ; [optional] $FindDepth - Value to add ; [optional] $TextToFind - ; [optional] $FindType - ; [optional] $TargetFileTypes - ; [optional] $TextInFileContent - ; Return values .: Success - array of result ; Failure - -1, sets @error ; |1 - $avArray is not an array ; |2 - $avArray is not a 1 dimensional array ; Author ........: HAMID ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: Yes ;MiniFinder("c:\windows",6,"run|notepad",0,"exe|avi") ; = find folders with "Run" or "notepad" or filetype with "exe" or avi ;MiniFinder("c:\windows",6,"run|notepad",1,"exe") ; = find files with "Run" or "notepad" name and filetype with is exe ;MiniFinder("c:\windows",6,"run|notepad",2) ; = find folders with "Run" or "notepad" ; =============================================================================================================================== ;$aFFL=$FindedFolderList ;$aSFFL=$SubFindedFolderList ;$aFResult = $aFindResult ;$FindType = Find File Or Folders #include <Timers.au3> #include<File.au3> #include<Array.au3> $Starttime = _Timer_Init() ; Temp $aFResult=MiniFinder("j:\",7,"") _ArrayDisplay($aFResult) $SecDiff=_Timer_Diff($starttime)/1000 ; Temp ConsoleWrite( "Running Time = > " & $SecDiff & @CRLF ) ; Temp Func MiniFinder($RootAddress,$FindDepth=-1,$TextToFind="",$FindType=0,$TargetFileTypes=-1,$TextInFileContent="") If $FindType=2 And $TargetFileTypes<>-1 Then $TargetFileTypes=-1 ConsoleWrite("Mini Finder : You can't define filetype in folder search" & @CRLF ) EndIf If StringRight($RootAddress,1)<>"\" Then $RootAddress = $RootAddress & "\" If $TargetFileTypes<>-1 Then $TargetFileTypes = "|" & $TargetFileTypes & "|" Dim $aFResult[1] Dim $aFFL[2] $aFFL[0]=1 $aFFL[1]=$RootAddress $i=1 While 1 $aSFFL=_FileListToArray($aFFL[$i],"*",0) If $i==$aFFL[0] And @error Then ExitLoop ; If Reached To last key of array and this key not have subdir If IsArray($aSFFL) Then $FolderCount=$aFFL[0] ReDim $aFFL[$aFFL[0]+1+$aSFFL[0]] $aFFL[0]=$aFFL[0]+$aSFFL[0] For $j= 1 To UBound($aSFFL)-1 $aFFL[$FolderCount+$j]=$aFFL[$i] & $aSFFL[$j] & "\" ; Add Folder Name To Search Array ( With \ ) If $FindType=0 Then ; add Files And Folders If Not StringInStr(FileGetAttrib($aFFL[$i] & $aSFFL[$j]),"D") Then ; Add file name ;---------------------> For Getting FileType/Filename and For No Wrong Change File Name $FindDot = StringSplit($aSFFL[$j], ".") If @error Then $FileType="*" ; $TargetFileTypes $FileName=$aSFFL[$j] Else _ArrayReverse($FindDot) Global $FileType=$FindDot[0] _ArrayReverse($FindDot) _ArrayPop($FindDot) Global $FileName=_ArrayToString($FindDot,".",1) EndIf ;---------------------> / For Getting FileType/Filename and For No Wrong Change File Name $TextToFindArray=StringSplit($TextToFind,"|") If @error Then If ($TextToFind="" Or StringInStr($FileName,$TextToFind)) And ($TargetFileTypes=-1 Or StringInStr($TargetFileTypes,"|" & $FileType & "|" )) Then $aFResult[0]=$aFResult[0]+1 ReDim $aFResult [$aFResult[0]+1] $aFResult[$aFResult[0]]=$aFFL[$i] & $aSFFL[$j] EndIf Else For $k=1 To UBound($TextToFindArray)-1 If StringInStr($FileName,$TextToFindArray[$k]) And ($TargetFileTypes=-1 Or StringInStr($TargetFileTypes,"|" & $FileType & "|" )) Then $aFResult[0]=$aFResult[0]+1 ReDim $aFResult [$aFResult[0]+1] $aFResult[$aFResult[0]]=$aFFL[$i] & $aSFFL[$j] EndIf Next EndIf Else ; add folder If StringInStr(FileGetAttrib($aFFL[$i] & $aSFFL[$j]),"D") Then $TextToFindArray=StringSplit($TextToFind,"|") If @error Then If ($TextToFind="" Or StringInStr($aSFFL[$j],$TextToFind)) Then $aFResult[0]=$aFResult[0]+1 ReDim $aFResult [$aFResult[0]+1] $aFResult[$aFResult[0]]=$aFFL[$i] & $aSFFL[$j] EndIf Else For $k=1 To UBound($TextToFindArray)-1 If StringInStr($aSFFL[$j],$TextToFindArray[$k]) Then $aFResult[0]=$aFResult[0]+1 ReDim $aFResult [$aFResult[0]+1] $aFResult[$aFResult[0]]=$aFFL[$i] & $aSFFL[$j] ExitLoop EndIf Next EndIf EndIf EndIf ElseIf $FindType=1 Then ;add File If Not StringInStr(FileGetAttrib($aFFL[$i] & $aSFFL[$j]),"D") Then ;---------------------> For Getting FileType/Filename and For No Wrong Change File Name $FindDot = StringSplit($aSFFL[$j], ".") If @error Then $FileType="*" ; $TargetFileTypes $FileName=$aSFFL[$j] Else _ArrayReverse($FindDot) Global $FileType=$FindDot[0] _ArrayReverse($FindDot) _ArrayPop($FindDot) Global $FileName=_ArrayToString($FindDot,".",1) EndIf ;---------------------> / For Getting FileType/Filename and For No Wrong Change File Name $TextToFindArray=StringSplit($TextToFind,"|") If @error Then If ($TextToFind="" Or StringInStr($FileName,$TextToFind)) And ($TargetFileTypes=-1 Or StringInStr($TargetFileTypes,"|" & $FileType & "|" )) Then $aFResult[0]=$aFResult[0]+1 ReDim $aFResult [$aFResult[0]+1] $aFResult[$aFResult[0]]=$aFFL[$i] & $aSFFL[$j] EndIf Else For $k=1 To UBound($TextToFindArray)-1 If StringInStr($FileName,$TextToFindArray[$k]) And ($TargetFileTypes=-1 Or StringInStr($TargetFileTypes,"|" & $FileType & "|" )) Then $aFResult[0]=$aFResult[0]+1 ReDim $aFResult [$aFResult[0]+1] $aFResult[$aFResult[0]]=$aFFL[$i] & $aSFFL[$j] EndIf Next EndIf EndIf ElseIf $FindType=2 Then ; Find Folders If StringInStr(FileGetAttrib($aFFL[$i] & $aSFFL[$j]),"D") Then $TextToFindArray=StringSplit($TextToFind,"|") If @error Then If ($TextToFind="" Or StringInStr($aSFFL[$j],$TextToFind)) Then $aFResult[0]=$aFResult[0]+1 ReDim $aFResult [$aFResult[0]+1] $aFResult[$aFResult[0]]=$aFFL[$i] & $aSFFL[$j] EndIf Else For $k=1 To UBound($TextToFindArray)-1 If StringInStr($aSFFL[$j],$TextToFindArray[$k]) Then $aFResult[0]=$aFResult[0]+1 ReDim $aFResult [$aFResult[0]+1] $aFResult[$aFResult[0]]=$aFFL[$i] & $aSFFL[$j] ExitLoop EndIf Next EndIf EndIf EndIf Next ;-----------------> Define Depth $aTempSplit=StringSplit($aFFL[$FolderCount+$j-1],"\") ; Scrutiny backslash number in Last Key If $aTempSplit[0]-3=$FindDepth Then ExitLoop ;-----------------> End Define Depth EndIf $aFFL[$i]="" $i=$i+1 WEnd If UBound($aFResult)>1 Then Return $aFResult Else Return 0 EndIf EndFuncMiniFinder.au3 MiniFinder Link to comment Share on other sites More sharing options...
AZJIO Posted September 9, 2011 Share Posted September 9, 2011 HAMIDIn the folder WINDOWS - 12 000 files, and script MiniFinder.au3 found more than 13 thousand. Run time 98 seconds.Look - 12 000 files in 0.25 seconds My other projects or all Link to comment Share on other sites More sharing options...
Yashied Posted September 9, 2011 Share Posted September 9, 2011 (edited) @HAMID You need to make friends with recursion. Edited September 9, 2011 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
HAMID Posted September 13, 2011 Author Share Posted September 13, 2011 hello @AZJIO i try to make beter version MiniFinder Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now