Jump to content

Recursive search with older than matching


druiddk
 Share

Recommended Posts

I found this recursive search Larry made a long time ago:

; _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("C:\surf\*.exe",0)
If $a[0] > 0 Then
    For $i = 1 to $a[0]
         MsgBox(4096,"",$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

I have been trying to make it only match on files before 2006/01/01 but cant seem to figure out where to stuff in the extra code.

This is surely very ineffective way to reach it but I was looking at doing it like this, sorry but I am not very good with AutoIT but trying :-)

#include <Date.au3>

$t = FileGetTime("c:\testfile", 0 , 1)

$year = StringLeft($t, 4)
$month = StringMid($t, 5, 2)
$day = StringMid($t, 7, 2)
$hour = StringMid($t, 9, 2)
$minute = StringMid($t, 11, 2)
$second = StringMid($t, 13, 2)

$t = $year & "/" & $month & "/" & $day & " " & $hour & ":" & $minute & ":" & $second
$i = _DateDiff('D', $t, "2006/01/01 00:00:00")

Any suggestions would be greatly appreciated.

Link to comment
Share on other sites

$t = FileGetTime("c:\testfile", 0 , 1)
if $t<"200601010000" Then
   ...add it.
Else
    ...dont add it. continue searchloop
Endif

Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...