Jump to content

Get the Largest file in the current directory


Recommended Posts

  • Moderators

Raffav,

So what have you tried that has not worked? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

i dont have no idea where to stat, i am makes some logical gess,

PS: the msgbox is for try to understand.

#include <File.au3>
#include <Array.au3>
;~ $dirPath = "C:UsersMarkoDesktoptest"
$fileArray = _FileListToArray(@ScriptDir,"*",1)
$fileSize = 0
$fileName = ""
$size = 1e10 ; Set a big number to start with
Local $fileSize[100]
For $i = 1 to UBound($fileArray) - 1
   $fileSize[$i] = FileGetSize($fileArray[$i])
   If $fileSize[$i] < $size Then ; Now see if this file is even smaller
        $size = $fileSize[$i]
        $fileName = $fileArray[$i]
   EndIf
Next
MsgBox(0, "Smallest file", "Smallest file is " & $fileName &" aaa "&$fileSize[1]&" aaa "&$fileSize[2]&" aaa "&$fileSize[3]&" aaa "&$fileSize[4]&" aaa "&$fileSize[5])
Link to comment
Share on other sites

  • Moderators

Rafav,

In other words - nothing. :)

OK, the last time you get a freebie for a while: :)

#include <File.au3>
#include <Array.au3>

; List the files
$aFileArray = _FileListToArray(@ScriptDir, "*.*", 1)

; Create a 2D array to hold the sizes and the names
Global $aFileSize[$aFileArray[0] + 1][2] = [[$aFileArray[0], 0]]

; Run through teh files and add the size and name to the 2D array
For $i = 1 To UBound($aFileArray) - 1
    $aFileSize[$i][0] = FileGetSize(@ScriptDir & "" & $aFileArray[$i])
    $aFileSize[$i][1] = $aFileArray[$i]
Next

; Sort the 2D array on the size column
_ArraySort($aFileSize, 1, 1)

; And here is the result!
_ArrayDisplay($aFileSize)

All clear? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • 3 weeks later...

Hello

i know that is freebie, but i trying to figure out how this part work principally in the Global and how it link the Name with the Size i think that is made in the For loop but i cant "Visualize it"

i figure out that the $aFileArray will hold the names one per index numbuer (dont know that is the correct name)

$aFileArray[0] ;= number of file/folder

$aFileArray[1] ;= 1 name file i dont figure out the order for indexing

$aFileArray[2] ;= 2 name file

.....

$aFileArray[N] ;= last namefile

-----------------------------------------------------------------

supposing that have 4 files in directory

the global will read +/- something like that:

Global $aFileSize[4 + 1][2] = [[5], 0]] is that logical right??

; Create a 2D array to hold the sizes and the names
Global $aFileSize[$aFileArray[0] + 1][2] = [[$aFileArray[0], 0]]
; Run through teh files and add the size and name to the 2D array
For $i = 1 To UBound($aFileArray) - 1
    $aFileSize[$i][0] = FileGetSize(@ScriptDir & "" & $aFileArray[$i])
    $aFileSize[$i][1] = $aFileArray[$i]
Next

Thanks

Sorry for bad English

Edited by Raffav
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...