Jump to content

all files found?


 Share

Recommended Posts

Filefindfirstfile()

Filefindnextfile()

Look At these in the help file

%flip

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

this dont work

; Shows the filenames of all files in the current directory
$search = FileFindFirstFile(@HomeDrive & "*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files Could be indexed.")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search)
    $size = FileGetSize($file)
    If @error Then ExitLoop
FileWriteLine("test.txt", $file & "|" & $size)
WEnd

; Close the search handle
FileClose($search)
Link to comment
Share on other sites

It works

I think you need to open the file before you write to it thou.

This is the same code but with a message box.

CODE
; Shows the filenames of all files in the current directory

$search = FileFindFirstFile(@HomeDrive & "*.*")

; Check if the search was successful

If $search = -1 Then

MsgBox(0, "Error", "No files Could be indexed.")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

$size = FileGetSize($file)

If @error Then ExitLoop

MsgBox(0,"aaa", $file & " " & $size)

;FileWriteLine("test.txt", $file & "|" & $size)

WEnd

; Close the search handle

FileClose($search)

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

This is a complete program with search engines.... maybe your "Simple Search" has already been made

http://www.autoitscript.com/forum/index.ph...st&p=141335

8)

yes maybe it has... but im gona make mine like neosearch... and openindex...

so it is quicker and nicer to look at... im only making it so i can learn form it...

Link to comment
Share on other sites

It works

I think you need to open the file before you write to it thou.

This is the same code but with a message box.

CODE
; Shows the filenames of all files in the current directory

$search = FileFindFirstFile(@HomeDrive & "*.*")

; Check if the search was successful

If $search = -1 Then

MsgBox(0, "Error", "No files Could be indexed.")

Exit

EndIf

While 1

$file = FileFindNextFile($search)

$size = FileGetSize($file)

If @error Then ExitLoop

MsgBox(0,"aaa", $file & " " & $size)

;FileWriteLine("test.txt", $file & "|" & $size)

WEnd

; Close the search handle

FileClose($search)

no it still only finds files the the scriptdir
Link to comment
Share on other sites

try something like:

#include <File.au3>
$lst = _FileListToArray(@HomeDrive, '*', 1)
For $i = 1 To $lst[0]
    $sz = Round(FileGetSize(@HomeDrive & '\' & $lst[$i]) / 1024, 1)
    FileWriteLine(@DesktopDir & '\ex.txt', $lst[$i] & " | " & $sz &' KB' & " | " & @HomeDrive & '\' & $lst[$i])
Next
$lstq = _FileListToArray(@HomeDrive, '*', 2)
For $j = 1 To $lstq[0]
    $sze = Round(DirGetSize(@HomeDrive & '\' & $lstq[$j]) / 1024, 1)
    FileWriteLine(@DesktopDir & '\ex.txt', $lstq[$j] & " | " & $sze &' KB' & " | " & @HomeDrive & '\' & $lstq[$j])
Next
Link to comment
Share on other sites

Hi,

-FileListToArray is slow, unless it has been fixed lately! - see alternative in link in my sig.

Otherwise, this is lifted from my 'searchMiner" ;see link to that too.

; files.au3
#include<array.au3>
#include<date.au3>
#include<file.au3>
local $s_Dir = FileSelectFolder("Choose a folder.", ""), $s_Array, $sFile="fileList.txt"
local $s_Array2 = _FileListToArrayRecurse2DL($s_Dir, $s_Array, "*", $sFile)
_ArrayDisplay($s_Array2,"Array",0,0,"~")
Func _FileListToArrayRecurse2DL($sPath, ByRef $sFileString, $sFilter = "*", $s_AnswerDos2 = "")
    If Not FileExists($sPath) Then Return SetError(1, 1, "")
    If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")
    Local $s_Xmas_Date = _DateTimeFormat("2006/12/25", 2), $i_InternationalDate;, $ar_Arrayalpha[$a]
    If StringLeft($s_Xmas_Date, 2) = "25" Then $i_InternationalDate = 1
    Local $Ret = _FileListToArrayRec1DL($sPath, $sFileString, $sFilter, $i_InternationalDate), $sFileString2 = StringTrimRight($sFileString, 1)
    $ar_Array = StringSplit($sFileString2, @CRLF, 1)
    $ar_Array[0] = $ar_Array[UBound($ar_Array) - 1]
    ReDim $ar_Array[UBound($ar_Array) - 1]
    _Array2D1DFieldSortSt ($ar_Array, "-4")
    Local $a = _FileWriteFromArray($s_AnswerDos2, $ar_Array), $s_AnswerDos3 = StringReplace($s_AnswerDos2, "New", "Recent"), $i_RecentUpper = UBound($ar_Array)
    If $i_RecentUpper > 50000 Then $i_RecentUpper = 50000
    _FileWriteFromArray($s_AnswerDos3, $ar_Array, 0, $i_RecentUpper); write recent files
    Return $ar_Array
EndFunc   ;==>_FileListToArrayRecurse2DL
Func _FileListToArrayRec1DL(ByRef $sPathF, ByRef $sFileStringF, ByRef $sFilterF, $i_InternationalDateF);, $iFlagF, $iRecurseF)
    Local $sFile, $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $i_InternationalDateF Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then
                SetError(0)
                ExitLoop
            EndIf
            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                _FileListToArrayRec1DL($sPathF2, $sFileStringF, $sFilterF, $i_InternationalDateF)
            Else; do this earlier and don't use else statement if want folders as well as files [0.7% faster only!]
                Local $Float = FileGetSize($sPathF2) * 1000 / 1048576, $fsize = StringFormat("%.2f", $Float)
                Local $s_Ext = "", $i_posDot = StringInStr($sFileF, ".", 0, -1), $ftime = "Unknown", $fgtime = FileGetTime($sPathF2)
                If @error <> 1 Then
                    If $i_posDot Then $s_Ext = StringMid($sFileF, $i_posDot + 1)
                    $ftime = $fgtime[0] & "-" & $fgtime[1] & "-" & $fgtime[2] & " at " & $fgtime[3] & ":" & $fgtime[4]
                    $ftime2 = $fgtime[2] & "-" & $fgtime[1] & "-" & $fgtime[0] & " at " & $fgtime[3] & ":" & $fgtime[4]
                    $sFileStringF &= $sFileF & "|" & $sPathF & "\" & "|" & $fsize & "|" & $ftime & "|" & $ftime2 & "|" & $s_Ext & @CRLF;& "*";this writes the filename to the delimited string
                Else
                    If $i_posDot Then $s_Ext = StringMid($sFileF, $i_posDot + 1)
                    $sFileStringF &= $sFileF & "|" & $sPathF & "\" & "|" & $fsize & "|||" & $s_Ext & @CRLF;& "*";this writes the filename to the delimited string
                EndIf
            EndIf
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then
                SetError(0)
                ExitLoop
            EndIf
            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                _FileListToArrayRec1DL($sPathF2, $sFileStringF, $sFilterF, $i_InternationalDateF)
            Else; do this earlier and don't use else statement if want folders as well as files [0.7% faster only!]
                Local $Float = FileGetSize($sPathF2) * 1000 / 1048576, $fsize = StringFormat("%.2f", $Float)
                Local $s_Ext = "", $i_posDot = StringInStr($sFileF, ".", 0, -1), $ftime = "Unknown", $fgtime = FileGetTime($sPathF2)
                If @error <> 1 Then
                    If $i_posDot Then $s_Ext = StringMid($sFileF, $i_posDot + 1)
                    $ftime = $fgtime[0] & "-" & $fgtime[1] & "-" & $fgtime[2] & " at " & $fgtime[3] & ":" & $fgtime[4]
                    $ftime2 = $fgtime[1] & "-" & $fgtime[2] & "-" & $fgtime[0] & " at " & $fgtime[3] & ":" & $fgtime[4]
                    $sFileStringF &= $sFileF & "|" & $sPathF & "\" & "|" & $fsize & "|" & $ftime & "|" & $ftime2 & "|" & $s_Ext & @CRLF;& "*";this writes the filename to the delimited string
                Else
                    If $i_posDot Then $s_Ext = StringMid($sFileF, $i_posDot + 1)
                    $sFileStringF &= $sFileF & "|" & $sPathF & "\" & "|" & $fsize & "|||" & $s_Ext & @CRLF;& "*";this writes the filename to the delimited string
                EndIf
            EndIf
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRec1DL
Func _Array2D1DFieldSortSt(ByRef $arEither2D1D, $iIndex = "1"); 1D must be "|" delimited!
    Local $code = 'function SubSort( byref arSingle,iIndex)'
    $code &= @LF & '    arIndexN=split(iIndex,"|")'
    $code &= @LF & '    dim iAsc:iAsc=0'
    $code &= @LF & '    if arIndexN(0)<0 then iAsc=1'
    $code &= @LF & '    dim arIndex()'
    $code &= @LF & '    redim preserve arIndex(1)';:arIndex(1) =0
    $code &= @LF & '    for a= 0 to ubound(arIndexN)'
    $code &= @LF & '        arIndexN(a)=csng(arIndexN(a))'
    $code &= @LF & '        if arIndexN(a)<>"" and arIndexN(a)<>0 then'
    $code &= @LF & '            redim preserve arIndex(a)'
    $code &= @LF & '            arIndex(a)=abs(arIndexN(a))-1'
    $code &= @LF & '            arIndexN(a)=csng(Iif(arIndexN(a)<0,arIndexN(a)+1,arIndexN(a)-1))'
    $code &= @LF & '        End If'
    $code &= @LF & '    next'
    $code &= @LF & '    ArraySort arSingle, iAsc,  0, UBound(arSingle), arIndex(0)  ';SortArray, iAsc,First, Last,iViewColNum
    $code &= @LF & '    for indexcol=1 to ubound(arIndex)';col=2'; start with check on 2nd  index'; define first index as col 1 (in call, 1)
    $code &= @LF & '        SubSort1 arSingle,arIndex,indexcol,iif(arIndexN(indexcol)<0,-1,1)  ';->, sort order
    $code &= @LF & '    Next'
    $code &= @LF & '    SubSort=arSingle'
    $code &= @LF & 'end function   ';==>ArrayFieldSort
    $code &= @LF & 'function SubSort1(byref arArray,arIndex,indexcol, iAsc)'
    $code &= @LF & '    dim Row,col:col=arIndex(indexcol)'
    $code &= @LF & '    dim pcol:pcol=arIndex(indexcol-1)'
    $code &= @LF & '    iAsc=Iif(iAsc<0,1,0)'
    $code &= @LF & '    dim arTemp(),itemp, sMarker:sMarker="Equal"';,sTemp(1)
    $code &= @LF & '    redim preserve arTemp(1) ';redim extra row
    $code &= @LF & '    for Row=1 to UBound(arArray) '; go through all rows of 2d array in that column to check for dupes
    $code &= @LF & '            arRow=split(arArray(row),"|")'
    $code &= @LF & '            arRowB4=split(arArray(row-1),"|")'
    $code &= @LF & '        if indexcol>1 then ';check cols in each row first if more than 2 index cols
    $code &= @LF & '            for c=0 to indexcol-1'
    $code &= @LF & '                if arRow(arIndex(c))<>arRowB4(arIndex(c)) Then'
    $code &= @LF & '                    sMarker="pColsNotEqual"'
    $code &= @LF & '                    c=indexcol'
    $code &= @LF & '                End If'
    $code &= @LF & '            Next'
    $code &= @LF & '        End If'
    $code &= @LF & '        if arRow(pcol)=arRowB4(pcol) and sMarker="Equal" Then ';dupes in the prev col.
    $code &= @LF & '            arTemp(itemp)=arArray(row-1)';Array2DToD( arArray2d,"",0,row-1,1) '; set first line of new potential sort array
    $code &= @LF & '            redim preserve arTemp(itemp+1) ';redim extra row
    $code &= @LF & '            arTemp(itemp+1)=arArray(row)';Array2DToD( arArray2d,"",0,row-1,1) '; set first line of new potential sort array
    $code &= @LF & '            itemp=itemp+1'
    $code &= @LF & '        Else'
    $code &= @LF & '            sMarker="Equal"'
    $code &= @LF & '            SubSortDo1 arArray,arTemp,itemp,iAsc,col,row'
    $code &= @LF & '        End If'
    $code &= @LF & '    Next'
    $code &= @LF & '    SubSortDo1 arArray,arTemp,itemp,iAsc,col,row'
    $code &= @LF & 'end function   '
    $code &= @LF & 'function SubSortDo1(byref arArray,byref arTemp,byref itemp,iAsc,col,row)'
    $code &= @LF & '    dim sTemp()'
    $code &= @LF & '    if itemp>0 then'
    $code &= @LF & '        ArraySort arTemp,  iAsc,0, UBound(arTemp), col ';sort on current col (pcol+1), asc?
    $code &= @LF & '        for i= 0 to ubound(arTemp)'
    $code &= @LF & '            arArray(row-ubound(arTemp)+i-1)=arTemp(i)'
    $code &= @LF & '        Next'
    $code &= @LF & '    End If'
    $code &= @LF & '    redim preserve arTemp(1)'
    $code &= @LF & '    itemp=0'; change backto single, then get into 2d array properly, then go on to check next line'; row=row-1??
    $code &= @LF & '    SubSortDo1= SortArray'
    $code &= @LF & 'end function'
    $code &= @LF & 'Function IIf( expr, truepart, falsepart )'
    $code &= @LF & '   IIf = falsepart'
    $code &= @LF & '   If expr Then IIf = truepart'''
    $code &= @LF & 'End Function'
    $code &= @LF & 'function ArraySort(ByRef SortArray, iAsc,First, Last,iViewColNum)'
    $code &= @LF & '    dim strWrite,arCol,arColumn()'
    $code &= @LF & '    ReDim Preserve arColumn(ubound(SortArray))'
    $code &= @LF & '    Dim intPointer, booIsNumeric: booIsNumeric = True'
    $code &= @LF & '    For intPointer = First To Last'
    $code &= @LF & '        arCol = Split( SortArray(intPointer), "|", -1,0 )'
    $code &= @LF & '        If Not IsNumeric( arCol(iViewColNum) ) Then'
    $code &= @LF & '            booIsNumeric = False'
    $code &= @LF & '            Exit For'
    $code &= @LF & '        End If'
    $code &= @LF & '    Next'
    $code &= @LF & '    For intPointer = First To Last'
    $code &= @LF & '        arCol = Split( SortArray(intPointer), "|", -1,0 )'
    $code &= @LF & '            If booIsNumeric Then'
    $code &= @LF & '            arColumn(intPointer)  = CSng( arCol(iViewColNum) )'
    $code &= @LF & '        else'
    $code &= @LF & '            arColumn(intPointer)  =  arCol(iViewColNum)'
    $code &= @LF & '        End If'
    $code &= @LF & '    Next'
    $code &= @LF & '    QuickSortColumn  SortArray, arColumn,First, Last,iViewColNum '
    $code &= @LF & '    if iasc=1 then ReverseElements SortArray, 0, ubound(SortArray)'
    $code &= @LF & '    ArraySort= SortArray'
    $code &= @LF & 'End function   '
    $code &= @LF & 'function QuickSortColumn(ByRef SortArray, ByRef arColumn, First, Last,iViewColNum)'
    $code &= @LF & '    dim Low,High,collitem,arCol'
    $code &= @LF & '    dim Temp,ListSeparator'
    $code &= @LF & '    Low = First'
    $code &= @LF & '    High = Last'
    $code &= @LF & '    ListSeparator=arColumn((First + Last) / 2)'
    $code &= @LF & '    Do'
    $code &= @LF & '        While (arColumn(Low) < ListSeparator)'
    $code &= @LF & '            Low = Low + 1'
    $code &= @LF & '        WEnd'
    $code &= @LF & '        While (arColumn(High) > ListSeparator)'
    $code &= @LF & '            High = High - 1'
    $code &= @LF & '        WEnd'
    $code &= @LF & '        If (Low <= High) Then'
    $code &= @LF & '            Temp = SortArray(Low)'
    $code &= @LF & '            SortArray(Low) = SortArray(High)'
    $code &= @LF & '            SortArray(High) = Temp'
    $code &= @LF & '            Temp = arColumn(Low)'
    $code &= @LF & '            arColumn(Low) = arColumn(High)'
    $code &= @LF & '            arColumn(High) = Temp'
    $code &= @LF & '            Low = Low + 1'
    $code &= @LF & '            High = High - 1'
    $code &= @LF & '        End If'
    $code &= @LF & '    Loop While (Low <= High)'
    $code &= @LF & '    If (First < High) Then QuickSortColumn  SortArray, arColumn,First, High,iViewColNum '
    $code &= @LF & '    If (Low < Last) Then QuickSortColumn  SortArray, arColumn,Low, Last,iViewColNum '
    $code &= @LF & 'End function   '
    $code &= @LF & 'Sub ReverseElements( arrToReverse, intAlphaRow, intOmegaRow )'
    $code &= @LF & '    Dim intPointer, intUpper, intLower, varHolder'
    $code &= @LF & '    For intPointer = 0 To Int( (intOmegaRow - intAlphaRow) / 2 )'
    $code &= @LF & '        intUpper = intAlphaRow + intPointer'
    $code &= @LF & '        intLower = intOmegaRow - intPointer'
    $code &= @LF & '        varHolder = arrToReverse(intLower)'
    $code &= @LF & '        arrToReverse(intLower) = arrToReverse(intUpper)'
    $code &= @LF & '        arrToReverse(intUpper) = varHolder'
    $code &= @LF & '    Next'
    $code &= @LF & 'End Sub'
    Local $vbs = ObjCreate("ScriptControl")
    $vbs.language = "vbscript"
    $vbs.Timeout = -1
    $vbs.addcode ($code)
;~  FileWrite(@ScriptDir&"\subsort.vbs",$code)
    $arEither2D1D = $vbs.Run("SubSort", $arEither2D1D, $iIndex)
    $vbs = ""
EndFunc   ;==>_Array2D1DFieldSortSt
Best, randall
Link to comment
Share on other sites

Hi,

-FileListToArray is slow, unless it has been fixed lately! - see alternative in link in my sig.

Otherwise, this is lifted from my 'searchMiner" ;see link to that too.

; files.au3
#include<array.au3>
#include<date.au3>
#include<file.au3>
local $s_Dir = FileSelectFolder("Choose a folder.", ""), $s_Array, $sFile="fileList.txt"
local $s_Array2 = _FileListToArrayRecurse2DL($s_Dir, $s_Array, "*", $sFile)
_ArrayDisplay($s_Array2,"Array",0,0,"~")
Func _FileListToArrayRecurse2DL($sPath, ByRef $sFileString, $sFilter = "*", $s_AnswerDos2 = "")
    If Not FileExists($sPath) Then Return SetError(1, 1, "")
    If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")
    Local $s_Xmas_Date = _DateTimeFormat("2006/12/25", 2), $i_InternationalDate;, $ar_Arrayalpha[$a]
    If StringLeft($s_Xmas_Date, 2) = "25" Then $i_InternationalDate = 1
    Local $Ret = _FileListToArrayRec1DL($sPath, $sFileString, $sFilter, $i_InternationalDate), $sFileString2 = StringTrimRight($sFileString, 1)
    $ar_Array = StringSplit($sFileString2, @CRLF, 1)
    $ar_Array[0] = $ar_Array[UBound($ar_Array) - 1]
    ReDim $ar_Array[UBound($ar_Array) - 1]
    _Array2D1DFieldSortSt ($ar_Array, "-4")
    Local $a = _FileWriteFromArray($s_AnswerDos2, $ar_Array), $s_AnswerDos3 = StringReplace($s_AnswerDos2, "New", "Recent"), $i_RecentUpper = UBound($ar_Array)
    If $i_RecentUpper > 50000 Then $i_RecentUpper = 50000
    _FileWriteFromArray($s_AnswerDos3, $ar_Array, 0, $i_RecentUpper); write recent files
    Return $ar_Array
EndFunc   ;==>_FileListToArrayRecurse2DL
Func _FileListToArrayRec1DL(ByRef $sPathF, ByRef $sFileStringF, ByRef $sFilterF, $i_InternationalDateF);, $iFlagF, $iRecurseF)
    Local $sFile, $hSearch = FileFindFirstFile($sPathF & "\" & $sFilterF), $sPathF2
    If $hSearch = -1 Then Return SetError(4, 4, "")
    If $i_InternationalDateF Then
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then
                SetError(0)
                ExitLoop
            EndIf
            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                _FileListToArrayRec1DL($sPathF2, $sFileStringF, $sFilterF, $i_InternationalDateF)
            Else; do this earlier and don't use else statement if want folders as well as files [0.7% faster only!]
                Local $Float = FileGetSize($sPathF2) * 1000 / 1048576, $fsize = StringFormat("%.2f", $Float)
                Local $s_Ext = "", $i_posDot = StringInStr($sFileF, ".", 0, -1), $ftime = "Unknown", $fgtime = FileGetTime($sPathF2)
                If @error <> 1 Then
                    If $i_posDot Then $s_Ext = StringMid($sFileF, $i_posDot + 1)
                    $ftime = $fgtime[0] & "-" & $fgtime[1] & "-" & $fgtime[2] & " at " & $fgtime[3] & ":" & $fgtime[4]
                    $ftime2 = $fgtime[2] & "-" & $fgtime[1] & "-" & $fgtime[0] & " at " & $fgtime[3] & ":" & $fgtime[4]
                    $sFileStringF &= $sFileF & "|" & $sPathF & "\" & "|" & $fsize & "|" & $ftime & "|" & $ftime2 & "|" & $s_Ext & @CRLF;& "*";this writes the filename to the delimited string
                Else
                    If $i_posDot Then $s_Ext = StringMid($sFileF, $i_posDot + 1)
                    $sFileStringF &= $sFileF & "|" & $sPathF & "\" & "|" & $fsize & "|||" & $s_Ext & @CRLF;& "*";this writes the filename to the delimited string
                EndIf
            EndIf
        WEnd
    Else
        While 1
            $sFileF = FileFindNextFile($hSearch)
            If @error Then
                SetError(0)
                ExitLoop
            EndIf
            $sPathF2 = $sPathF & "\" & $sFileF
            If StringInStr(FileGetAttrib($sPathF2), "D") Then
                _FileListToArrayRec1DL($sPathF2, $sFileStringF, $sFilterF, $i_InternationalDateF)
            Else; do this earlier and don't use else statement if want folders as well as files [0.7% faster only!]
                Local $Float = FileGetSize($sPathF2) * 1000 / 1048576, $fsize = StringFormat("%.2f", $Float)
                Local $s_Ext = "", $i_posDot = StringInStr($sFileF, ".", 0, -1), $ftime = "Unknown", $fgtime = FileGetTime($sPathF2)
                If @error <> 1 Then
                    If $i_posDot Then $s_Ext = StringMid($sFileF, $i_posDot + 1)
                    $ftime = $fgtime[0] & "-" & $fgtime[1] & "-" & $fgtime[2] & " at " & $fgtime[3] & ":" & $fgtime[4]
                    $ftime2 = $fgtime[1] & "-" & $fgtime[2] & "-" & $fgtime[0] & " at " & $fgtime[3] & ":" & $fgtime[4]
                    $sFileStringF &= $sFileF & "|" & $sPathF & "\" & "|" & $fsize & "|" & $ftime & "|" & $ftime2 & "|" & $s_Ext & @CRLF;& "*";this writes the filename to the delimited string
                Else
                    If $i_posDot Then $s_Ext = StringMid($sFileF, $i_posDot + 1)
                    $sFileStringF &= $sFileF & "|" & $sPathF & "\" & "|" & $fsize & "|||" & $s_Ext & @CRLF;& "*";this writes the filename to the delimited string
                EndIf
            EndIf
        WEnd
    EndIf
    FileClose($hSearch)
EndFunc   ;==>_FileListToArrayRec1DL
Func _Array2D1DFieldSortSt(ByRef $arEither2D1D, $iIndex = "1"); 1D must be "|" delimited!
    Local $code = 'function SubSort( byref arSingle,iIndex)'
    $code &= @LF & '    arIndexN=split(iIndex,"|")'
    $code &= @LF & '    dim iAsc:iAsc=0'
    $code &= @LF & '    if arIndexN(0)<0 then iAsc=1'
    $code &= @LF & '    dim arIndex()'
    $code &= @LF & '    redim preserve arIndex(1)';:arIndex(1) =0
    $code &= @LF & '    for a= 0 to ubound(arIndexN)'
    $code &= @LF & '        arIndexN(a)=csng(arIndexN(a))'
    $code &= @LF & '        if arIndexN(a)<>"" and arIndexN(a)<>0 then'
    $code &= @LF & '            redim preserve arIndex(a)'
    $code &= @LF & '            arIndex(a)=abs(arIndexN(a))-1'
    $code &= @LF & '            arIndexN(a)=csng(Iif(arIndexN(a)<0,arIndexN(a)+1,arIndexN(a)-1))'
    $code &= @LF & '        End If'
    $code &= @LF & '    next'
    $code &= @LF & '    ArraySort arSingle, iAsc,  0, UBound(arSingle), arIndex(0)  ';SortArray, iAsc,First, Last,iViewColNum
    $code &= @LF & '    for indexcol=1 to ubound(arIndex)';col=2'; start with check on 2nd  index'; define first index as col 1 (in call, 1)
    $code &= @LF & '        SubSort1 arSingle,arIndex,indexcol,iif(arIndexN(indexcol)<0,-1,1)  ';->, sort order
    $code &= @LF & '    Next'
    $code &= @LF & '    SubSort=arSingle'
    $code &= @LF & 'end function   ';==>ArrayFieldSort
    $code &= @LF & 'function SubSort1(byref arArray,arIndex,indexcol, iAsc)'
    $code &= @LF & '    dim Row,col:col=arIndex(indexcol)'
    $code &= @LF & '    dim pcol:pcol=arIndex(indexcol-1)'
    $code &= @LF & '    iAsc=Iif(iAsc<0,1,0)'
    $code &= @LF & '    dim arTemp(),itemp, sMarker:sMarker="Equal"';,sTemp(1)
    $code &= @LF & '    redim preserve arTemp(1) ';redim extra row
    $code &= @LF & '    for Row=1 to UBound(arArray) '; go through all rows of 2d array in that column to check for dupes
    $code &= @LF & '            arRow=split(arArray(row),"|")'
    $code &= @LF & '            arRowB4=split(arArray(row-1),"|")'
    $code &= @LF & '        if indexcol>1 then ';check cols in each row first if more than 2 index cols
    $code &= @LF & '            for c=0 to indexcol-1'
    $code &= @LF & '                if arRow(arIndex(c))<>arRowB4(arIndex(c)) Then'
    $code &= @LF & '                    sMarker="pColsNotEqual"'
    $code &= @LF & '                    c=indexcol'
    $code &= @LF & '                End If'
    $code &= @LF & '            Next'
    $code &= @LF & '        End If'
    $code &= @LF & '        if arRow(pcol)=arRowB4(pcol) and sMarker="Equal" Then ';dupes in the prev col.
    $code &= @LF & '            arTemp(itemp)=arArray(row-1)';Array2DToD( arArray2d,"",0,row-1,1) '; set first line of new potential sort array
    $code &= @LF & '            redim preserve arTemp(itemp+1) ';redim extra row
    $code &= @LF & '            arTemp(itemp+1)=arArray(row)';Array2DToD( arArray2d,"",0,row-1,1) '; set first line of new potential sort array
    $code &= @LF & '            itemp=itemp+1'
    $code &= @LF & '        Else'
    $code &= @LF & '            sMarker="Equal"'
    $code &= @LF & '            SubSortDo1 arArray,arTemp,itemp,iAsc,col,row'
    $code &= @LF & '        End If'
    $code &= @LF & '    Next'
    $code &= @LF & '    SubSortDo1 arArray,arTemp,itemp,iAsc,col,row'
    $code &= @LF & 'end function   '
    $code &= @LF & 'function SubSortDo1(byref arArray,byref arTemp,byref itemp,iAsc,col,row)'
    $code &= @LF & '    dim sTemp()'
    $code &= @LF & '    if itemp>0 then'
    $code &= @LF & '        ArraySort arTemp,  iAsc,0, UBound(arTemp), col ';sort on current col (pcol+1), asc?
    $code &= @LF & '        for i= 0 to ubound(arTemp)'
    $code &= @LF & '            arArray(row-ubound(arTemp)+i-1)=arTemp(i)'
    $code &= @LF & '        Next'
    $code &= @LF & '    End If'
    $code &= @LF & '    redim preserve arTemp(1)'
    $code &= @LF & '    itemp=0'; change backto single, then get into 2d array properly, then go on to check next line'; row=row-1??
    $code &= @LF & '    SubSortDo1= SortArray'
    $code &= @LF & 'end function'
    $code &= @LF & 'Function IIf( expr, truepart, falsepart )'
    $code &= @LF & '   IIf = falsepart'
    $code &= @LF & '   If expr Then IIf = truepart'''
    $code &= @LF & 'End Function'
    $code &= @LF & 'function ArraySort(ByRef SortArray, iAsc,First, Last,iViewColNum)'
    $code &= @LF & '    dim strWrite,arCol,arColumn()'
    $code &= @LF & '    ReDim Preserve arColumn(ubound(SortArray))'
    $code &= @LF & '    Dim intPointer, booIsNumeric: booIsNumeric = True'
    $code &= @LF & '    For intPointer = First To Last'
    $code &= @LF & '        arCol = Split( SortArray(intPointer), "|", -1,0 )'
    $code &= @LF & '        If Not IsNumeric( arCol(iViewColNum) ) Then'
    $code &= @LF & '            booIsNumeric = False'
    $code &= @LF & '            Exit For'
    $code &= @LF & '        End If'
    $code &= @LF & '    Next'
    $code &= @LF & '    For intPointer = First To Last'
    $code &= @LF & '        arCol = Split( SortArray(intPointer), "|", -1,0 )'
    $code &= @LF & '            If booIsNumeric Then'
    $code &= @LF & '            arColumn(intPointer)  = CSng( arCol(iViewColNum) )'
    $code &= @LF & '        else'
    $code &= @LF & '            arColumn(intPointer)  =  arCol(iViewColNum)'
    $code &= @LF & '        End If'
    $code &= @LF & '    Next'
    $code &= @LF & '    QuickSortColumn  SortArray, arColumn,First, Last,iViewColNum '
    $code &= @LF & '    if iasc=1 then ReverseElements SortArray, 0, ubound(SortArray)'
    $code &= @LF & '    ArraySort= SortArray'
    $code &= @LF & 'End function   '
    $code &= @LF & 'function QuickSortColumn(ByRef SortArray, ByRef arColumn, First, Last,iViewColNum)'
    $code &= @LF & '    dim Low,High,collitem,arCol'
    $code &= @LF & '    dim Temp,ListSeparator'
    $code &= @LF & '    Low = First'
    $code &= @LF & '    High = Last'
    $code &= @LF & '    ListSeparator=arColumn((First + Last) / 2)'
    $code &= @LF & '    Do'
    $code &= @LF & '        While (arColumn(Low) < ListSeparator)'
    $code &= @LF & '            Low = Low + 1'
    $code &= @LF & '        WEnd'
    $code &= @LF & '        While (arColumn(High) > ListSeparator)'
    $code &= @LF & '            High = High - 1'
    $code &= @LF & '        WEnd'
    $code &= @LF & '        If (Low <= High) Then'
    $code &= @LF & '            Temp = SortArray(Low)'
    $code &= @LF & '            SortArray(Low) = SortArray(High)'
    $code &= @LF & '            SortArray(High) = Temp'
    $code &= @LF & '            Temp = arColumn(Low)'
    $code &= @LF & '            arColumn(Low) = arColumn(High)'
    $code &= @LF & '            arColumn(High) = Temp'
    $code &= @LF & '            Low = Low + 1'
    $code &= @LF & '            High = High - 1'
    $code &= @LF & '        End If'
    $code &= @LF & '    Loop While (Low <= High)'
    $code &= @LF & '    If (First < High) Then QuickSortColumn  SortArray, arColumn,First, High,iViewColNum '
    $code &= @LF & '    If (Low < Last) Then QuickSortColumn  SortArray, arColumn,Low, Last,iViewColNum '
    $code &= @LF & 'End function   '
    $code &= @LF & 'Sub ReverseElements( arrToReverse, intAlphaRow, intOmegaRow )'
    $code &= @LF & '    Dim intPointer, intUpper, intLower, varHolder'
    $code &= @LF & '    For intPointer = 0 To Int( (intOmegaRow - intAlphaRow) / 2 )'
    $code &= @LF & '        intUpper = intAlphaRow + intPointer'
    $code &= @LF & '        intLower = intOmegaRow - intPointer'
    $code &= @LF & '        varHolder = arrToReverse(intLower)'
    $code &= @LF & '        arrToReverse(intLower) = arrToReverse(intUpper)'
    $code &= @LF & '        arrToReverse(intUpper) = varHolder'
    $code &= @LF & '    Next'
    $code &= @LF & 'End Sub'
    Local $vbs = ObjCreate("ScriptControl")
    $vbs.language = "vbscript"
    $vbs.Timeout = -1
    $vbs.addcode ($code)
;~  FileWrite(@ScriptDir&"\subsort.vbs",$code)
    $arEither2D1D = $vbs.Run("SubSort", $arEither2D1D, $iIndex)
    $vbs = ""
EndFunc   ;==>_Array2D1DFieldSortSt
Best, randall

i get an error...

@Gif

Sorry that not what im looking for... i want it to find every file on my pc...

Thanks for trying anyways...

Link to comment
Share on other sites

yes maybe it has... but im gona make mine like neosearch... and openindex...

so it is quicker and nicer to look at... im only making it so i can learn form it...

If this is meant as an instructional exercise, do it this way to learn a very useful skill -- recursive function:

Write a func that will list all the files and folders in a single directory, stepping through and listing each one in an array or something.

Make sure every variable used is local.

Make it differentiate between files and folders.

Make it call itself passing the folder as the new parameter, and adding the list returned to it's own list.

Each call to the the func only lists that one directory, and makes the recursive call for each subdirectory.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

If this is meant as an instructional exercise, do it this way to learn a very useful skill -- recursive function:

Write a func that will list all the files and folders in a single directory, stepping through and listing each one in an array or something.

Make sure every variable used is local.

Make it differentiate between files and folders.

Make it call itself passing the folder as the new parameter, and adding the list returned to it's own list.

Each call to the the func only lists that one directory, and makes the recursive call for each subdirectory.

:)

what

XP

Link to comment
Share on other sites

$drives = DriveGetDrive ( "ALL" ); this will search all you may want to change it to only search fixed
$list= FileOPen(@scriptDir & "\index.txt",2)

For $i = 1 to Ubound($drives) -1
    _Index($drives[$i])
Next

FileClose($list)

Func _Index($path)

    Local $search = FileFindFirstFile($path & "\*.*")
    While 1
        Dim $file = FileFindNextFile($search)
        If @error Or StringLen($file) < 1 Then ExitLoop
        If Not StringInStr(FileGetAttrib($path & "\" & $file), "D") Then
            
            $size = FileGetSize($path & "\" & $file)
            FileWriteLine($list,$file & "|" & $size & "|" & $path)
           
        EndIf
        If StringInStr(FileGetAttrib($path & "\" & $file), "D")  Then
            _Index($path & "\" & $file)
            
        EndIf
        Sleep (1);stop too much cpu thrashing
    WEnd
    FileClose($search)

EndFunc

Edit: took out a line from my app that uses part of this

Edited by ChrisL
Link to comment
Share on other sites

$drives = DriveGetDrive ( "ALL" ); this will search all you may want to change it to only search fixed
$list= FileOPen(@scriptDir & "\index.txt",2)

For $i = 1 to Ubound($drives) -1
    _Index($drives[$i])
Next

FileClose($list)

Func _Index($path)

    Local $search = FileFindFirstFile($path & "\*.*")
    While 1
        Dim $file = FileFindNextFile($search)
        If @error Or StringLen($file) < 1 Then ExitLoop
        If Not StringInStr(FileGetAttrib($path & "\" & $file), "D") Then
            
            $size = FileGetSize($path & "\" & $file)
            FileWriteLine($list,$file & "|" & $size & "|" & $path)
           
        EndIf
        If StringInStr(FileGetAttrib($path & "\" & $file), "D")  Then
            _Index($path & "\" & $file)
            
        EndIf
        Sleep (1);stop too much cpu thrashing
    WEnd
    FileClose($search)

EndFunc

Edit: took out a line from my app that uses part of this

dude thanks...

but how do i get it to show a progress bar... while doing it.. and then another functions to search that file and show what it findes (like neosearch)

Link to comment
Share on other sites

  • Moderators

dude thanks...

but how do i get it to show a progress bar... while doing it.. and then another functions to search that file and show what it findes (like neosearch)

You like being hand fed don't you...

1. Use the search button.

2. Show an attempt.

3. After failure and showing how you failed ask for help.

It was kind of rediculous that you got 4 answers that worked, and you said "not" what I'm looking for, maybe you should learn to phrase your questions properly to get the exact answer your looking for rather than having people jumping through hoops for you.

BTW... Randal's is going to much faster than anything else you've seen here... instead of saying you got an error, why not look in his signature, download the files, and see what they are doing so you can accomplish what you are trying to do to your own satisfaction.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

i get an error...

Hi,

That's disappointing; it could be very helpful for me to know why my script might not work on other people's computers..

Would you be able to post the error message [ie copied from complete console output]? I would be very grateful if you could say when it occurred, which folder you chose, whether reproducable on all folders, etc?

Thanks, Randall

[** never mind if you changed the filter; I see it will not work if you are not looking for all files; you could still look at modifying my "FilelistToArray", though... I see @ChrisL has a good one anyway..]

Edited by randallc
Link to comment
Share on other sites

You like being hand fed don't you...

1. Use the search button.

2. Show an attempt.

3. After failure and showing how you failed ask for help.

It was kind of rediculous that you got 4 answers that worked, and you said "not" what I'm looking for, maybe you should learn to phrase your questions properly to get the exact answer your looking for rather than having people jumping through hoops for you.

BTW... Randal's is going to much faster than anything else you've seen here... instead of saying you got an error, why not look in his signature, download the files, and see what they are doing so you can accomplish what you are trying to do to your own satisfaction.

I was waiting for someone to say this. I thought it rather funny that he said he's doing this for a learning experience, yet asking everyone else to do the code for him. I don't remember learning math by having my teachers do my homework for me. :)

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...