Jump to content

FileFindNextFile


masvil
 Share

Recommended Posts

  • Moderators

Stick all that information into an array? That sounds like it would take an awfully long time... maybe someone has something with using dos or something

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

Oh, now I understand your question.

Not yet :geek:

Example: FileFindFirstFile matches these 3 files:

- 1.txt (70k)

- 2.txt (18k)

- 3.txt (90k)

How can I make FileFindNextFile processes them in size order (3.txt then 1.txt then 2.txt) instead of name order (even if I still haven't understood which is default order)?

I hope I've been clearer.

@Valuater: not so much :o

Edited by masvil
Link to comment
Share on other sites

  • Moderators

Ya'll are going in circles on this subject, as I stated, you'd have to read all that information individually and store it into an array, then pull from it what specifically you are looking for.

Or maybe someone can do it via a dos command or something, which would be much faster I'm sure.

Edit:

Example from help

$search = FileFindFirstFile("*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    
    MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)

Put in that loop something like under $file-- $FileSize = $Filesize & FileGetSize($file) / 1024 & Chr(01) or something then StringSplit() it. Then you would work from the stringsplit for filesize.

Edited by SmOke_N

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

this will do the trick

#Include <File.au3>
#Include <Array.au3>

Dim $Location = @DesktopDir & "\"

$FileList = _FileListToArray ($Location)
If (Not IsArray($FileList)) and (@error = 1) Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf
Dim $Nfile[$FileList[0]]
For $x = 1 To $FileList[0] -1
    $Temp_info = FileGetSize($Location & $FileList[$x])
    $Nfile[$x] = $Temp_info & "," & $FileList[$x]
Next

ArraySortNum($Nfile, 0)
_ArrayDisplay($Nfile, " Files Sorted by Size")


; Author - SmOke_N
Func ArraySortNum(ByRef $nArray, $Ascending = 0, $Start = 1)
    For $i = $Start To UBound($nArray) - 2
        Local $SE = $i
        If $Ascending = 0 Then
            For $x = $i To UBound($nArray) - 1
                If Number($nArray[$SE]) < Number($nArray[$x]) Then $SE = $x
            Next
        Else
            For $x = $i To UBound($nArray) - 1
                If Number($nArray[$SE]) > Number($nArray[$x]) Then $SE = $x
            Next
        EndIf
        Local $HLD = $nArray[$i]
        $nArray[$i] = $nArray[$SE]
        $nArray[$SE] = $HLD
    Next
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

the first file found... then the second file found etc.. etc

Hm, back to example.

Example: FileFindFirstFile matches these 3 files:

- 2.txt (18k)

- 1.txt (70k)

- 3.txt (90k)

In which order (and why) FileFindNextFile find each of them?

Edited by masvil
Link to comment
Share on other sites

i just did a quick and dirty test with 3 jpg files named 1,2 and 3. FileFindNextFile seems to find them in that order 1 2 3 regardless of size or date created. like i say quick and dirty. hope this helps answer your original question.

I would guess that they are copied in the order they are created and stored in the table of contents in windows.. I could be wrong though!!

Link to comment
Share on other sites

i don't want to beat a dead horse here but here's what i did. created 3 jpg files. named them 123, creation times are in that order 12:50 12:51 12:52. FileFindNextFile listed them 123. i renamed file 1 to 3 and so on, FileFindNextFile still found them 123. of course when i renamed them did i change the modified date? i forgot to look. i'm really not sure what the answer is.

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